I haven't looked at the code, but I see mention of Sleep(0) here. Does
everyone realize the special behavior of Sleep(0) ?
It only gives up a timeslice to threads of >= priority. Starving lower
priority threads (if you were to spin with only that).
Not sure it is a problem inthis case, but wanted to mention it, as it is
often overlooked.
Tony
Sent from my portable Analytical Engine
------------------------------
*From:* "Ion Gaztañaga"
But the timeslice is not necessarily 20ms. A call to timeBeginPeriod(1) may shorten it.
timeBeginPeriod seems a bit scary as it affects the general windows scheduler. One option could be to call GetTickCount until it changes its value twice (as the resolution of this time is the resolution of the system timer). Once it changes (after 20-40ms looping, on average that would me 30ms), then Sleep(1) is called. And for uniprocessor systems we should avoid doing any loop and call only Sleep(0). But that would be a really hard to implement spinlock ;-) Another option is to obtain the a high resolution timestamp each loop and just loop, say, for 100ms before going to Sleep(1). Best, Ion _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost