[SDL] Using SDL_PushEvent

Marcin Konicki ahwayakchih at neoni.net
Wed Mar 16 21:19:10 PST 2005

> I seem to recall a reference specifically indicating that SDL_PushEvent 
> could be used to push events from other threads to the main thread, but 
> I can't seem to find it in the docs, modulo a reference to being able to 
> use SDL_PushEvent from timer functions.
> I see that SDL_PeepEvents can be used to add events to the main event 
> queue and is explicitly marked in the man page as being thread-safe. 
> Looking at the SDL 1.2.7 source, I see:
> int SDL_PushEvent(SDL_Event *event)
> {
>         if ( SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0 )
>                 return -1;
>         return 0;
> }
> which means that SDL_PushEvent just wraps SDL_PeepEvents, so it should 
> be safe to use it from any thread.  Is there any authoritative 
> documentation indicating that that's guaranteed to be the case, though?

Heh, i should have read all mails before replying :).

AFAIK there's no official docs, but after looking into the source code, it 
seems SDL_PushEvent and SDL_PeepEvents are safe to be called from any 
thread - event queue is locked before any changes.


More information about the SDL mailing list