I’m a bit confused about notes in SDL_PumpEvents, SDL_PollEvent, etc
*Note: *You can only call this function in the thread that set the video
As this function implicitly calls SDL_PumpEventshttp://www.libsdl.org/cgi/docwiki.cgi/SDL_PumpEvents,
you can only call this function in the thread that set the video mode.
This function is thread safe, and can be called from other threads safely.
It is not clear why this note is there. Possibilities include:
SDL doesn’t use Posix threads so the queues are in different memory
segments not shared/accessible across the threads
Evidence against: SDL source includes pthread references,
Evidence for: but it not exactly clear which platforms use pthreads
SDL doesn’t have thread mutexs around the SDL_PumpEvents, and
SDL_PollEvents, but SDL_PushEvents is wrapped in mutexs
Evidence for: SDL_PumpEvents, SDL_PollEvents, SDL_PushEvents have no mutexes
but they all call SDL_PeepEvents
Evidence against: SDL_PeepEvents has mutexs
So, neither of the above seem to answer my question. The "important"
rountne SDL_PeepEvents seems to be thread safe, pthreads is used, so why the
warning against initializing the video in one thread and grabbing events in
Jason Harrison, PhD
Cell: 604 644 8611
Thanks to Yggy King for bringing this quote to my attention:
Thinking the world should entertain you leads to boredom and sloth. Thinking
you should entertain the world leads to bright clothes, odd graffiti and
amazing grace in running for the bus. – Ann Herbert