Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#ActualN01

Posted 10 September 2013 - 08:08 AM

 

Wait, is that actually representative of your actual code? Those calls to sleep (especially in the physics thread) will not be doing you any good.

The accumulation loop you posted is design to run as quickly as possible (i.e. in a while(true) style loop) and fire the Physics events at the correct time. With the setup you have now the simulation will not be being called at the correct frequency due to differences in sleep time and the fact that your time deltas are going to be huge.

 

this is simplified code. but yes, my threads do sleep, but they also do take in account time they were busy with processing, so they don't sleep more than it's required. and my deltaTime is not really huge, it's always around 0.033sec with rare deviations of 0.001sec. this loop is not designed to run continuously, it's designed to compensate for elapsed time. the only case, then such organisation may cause trouble, is if processingThread cannot finish in given time of 30ms, but that is undesirable for application in general, so i shouldn't allow it to happen. and you generally don't want any continuous  thread to run without any sleeping, it is similarly irresponsible and dumb as using vsync to limit your framerate.


#2N01

Posted 10 September 2013 - 07:18 AM

 

Wait, is that actually representative of your actual code? Those calls to sleep (especially in the physics thread) will not be doing you any good.

The accumulation loop you posted is design to run as quickly as possible (i.e. in a while(true) style loop) and fire the Physics events at the correct time. With the setup you have now the simulation will not be being called at the correct frequency due to differences in sleep time and the fact that your time deltas are going to be huge.

 

this is simplified code. but yes, my threads do sleep, but they also do take in account time they were busy with processing, so they don't sleep more than it's required. and my deltaTime is not really huge, it's always around 0.033sec with rare deviations of 0.001sec. this loop is not designed to run continuously, it's designed to wait until it's time to simulate again. the only case, then such organisation may cause trouble, is if processingThread cannot finish in given time of 30ms, but that is undesirable for application in general, so i shouldn't allow it to happen. and you generally don't want any continuous  thread to run without any sleeping, it is similarly irresponsible and dumb as using vsync to limit your framerate.


#1N01

Posted 10 September 2013 - 07:18 AM

 

Wait, is that actually representative of your actual code? Those calls to sleep (especially in the physics thread) will not be doing you any good.

The accumulation loop you posted is design to run as quickly as possible (i.e. in a while(true) style loop) and fire the Physics events at the correct time. With the setup you have now the simulation will not be being called at the correct frequency due to differences in sleep time and the fact that your time deltas are going to be huge.

 

whis is simplified code. but yes, my threads do sleep, but they also do take in account time they were busy with processing, so they don't sleep more than it's required. and my deltaTime is not really huge, it's always around 0.033sec with rare deviations of 0.001sec. this loop is not designed to run continuously, it's designed to wait until it's time to simulate again. the only case, then such organisation may cause trouble, is if processingThread cannot finish in given time of 30ms, but that is undesirable for application in general, so i shouldn't allow it to happen. and you generally don't want any continuous  thread to run without any sleeping, it is similarly irresponsible and dumb as using vsync to limit your framerate.


PARTNERS