Multithreading questions and good practices

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Multithreading questions and good practices

Postby godlike » Fri Dec 12, 2014 4:35 pm

By looking into the Newton.h I saw quite a few multithreading related functions and I was wondering how to utilize Newton's multithreading capabilities better.

An (easy) assumption is that NewtonSetThreadsCount will set the number of worker threads. The NewtonUpdate() will distribute the world update across Newton's threads and it will wait for them to finish. NewtonUpdateAsync will fire the world update across the threads and return without waiting. NewtonWaitForUpdateToFinish will wait for the async update.

Now, between NewtonUpdateAsync and NewtonWaitForUpdateToFinish I am not allowed to call other newton functions. Eg I cannot create and delete bodies for example.

Are these assumptions correct? Is there anything else I should know in order to get better performance?
User avatar
godlike
 
Posts: 58
Joined: Sun Mar 16, 2014 3:48 am

Re: Multithreading questions and good practices

Postby Julio Jerez » Fri Dec 12, 2014 8:51 pm

you got almost all right.
after you call NewtonWaitForUpdateToFinish, you can issue any newton Call.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multithreading questions and good practices

Postby godlike » Sat Dec 13, 2014 4:47 am

Thanks for the answer. I really like that Newton's API is so damn logical.
User avatar
godlike
 
Posts: 58
Joined: Sun Mar 16, 2014 3:48 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest