[SDL] no SDL_YieldThread() function?

Bob Ippolito bob at redivi.com
Sun Mar 6 23:25:49 PST 2005


On Mar 7, 2005, at 1:33 AM, Ryan C. Gordon wrote:

>
>> Nope, that's an undocumented side effect of the way the underlying 
>> Win32 call works.
>> For example, SDL_Delay(0) on Linux does precisely nothing. (At least, 
>> that was the case last time I checked.)
>
> David's right, but an SDL_Delay(10) (or perhaps even an 
> SDL_Delay(100), depending on the thread in question) works wonders in 
> most places.

Since SDL only supports pre-emptive multithreading, the OS is already 
going to switch between threads as best as it sees fit.  What use is 
delaying for some arbitrary fixed time going to do, other than make 
sure that some CPU slices end up somewhere else?  Also, delaying for 
some fixed time interval is going to mean different things to different 
machines.  A slower machine is going to want less of a delay and a 
faster machine is going to want more.

If you design your application to be event driven, so that it's 
processing when it needs to be, and sleeping otherwise (waiting for an 
event or some specific time), then you don't have to worry about this 
because you're using the CPU only when you need it.

-bob





More information about the SDL mailing list