Oh yeah. It's all awesome, except that: And, uhm, the behavior of Sleep(0) is actually well-defined, so if you want something else, then you shouldn't blame Sleep(0) for that.
You mean this definition?
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread that is ready to run. If there are no other threads ready to run, the function returns immediately, and the thread continues execution.
This is a new definition and doesn't apply to XP which is still largely used around the world so we have to use the "worst" case definition... Which is that it will only give up to to at least equal or higher priority threads. And nightmare scenarios could force your application into a stagnation problem.
Statistics from 2011 December:
Win7 Vista Win2003 WinXP Linux Mac Mobile
46.1% 5.0% 0.7% 32.6% 4.9% 8.5% 1.2%
That's the definition of Sleep 0 on Windows yes. POSIX don't have any defined behavior for sleep 0. Closest you can get is shed_yield. And still on windows, even if they do have a defined behavior for Sleep 0, they also have a lot of associated problems with this usage on Windows. That they themselves have documented.
And don't hi-jack threads.