Forum Replies Created
Viewing 1 post (of 1 total)
- AuthorPosts
- si_icarusParticipant
Actually, I think I’ve actually identified the problem. I think it was the sleep() function in my thread loop. I understand why I need that if the loop is continuously running and doing heavy stuff, but do I need it in my case?
When I comment out the sleep line (As below), the behaviour looks a lot smoother and correct, maybe because as soon as I set the bHasRunThisFrame flag in the thread instance to false, the update function is called almost immediately (which is what I want), whereas with the sleep() function, maybe there was a delay of upto interval before the update kicked in?…. or something :P Is it bad to not have a sleep function in there?
// run the update function in another thread
123456789101112131415void MSAThread::threadedFunction() {<br />while(isThreadRunning()) {<br />if( lock() ){<br />if(bAutoLoop || !bHasRunThisFrame) {<br />update();<br />bHasRunThisFrame = true;<br />unlock();<br />// ofSleepMillis(interval);<br />} else {<br />unlock();<br />}<br />}<br />}<br />}<br /> - AuthorPosts
Viewing 1 post (of 1 total)