Being a slightly backward sort, I originally posted this message to
news.lokigames.com. It doesn’t appear to have been propagated from there, so
I’m posting it again to gmane.org. I apologise if it did appear and I’m just
suffering temporary blindness. My post:
I am attempting my first multithreaded program with SDL, having previous
experience with various specific OSs. But I am confused by SDL_CondWait. Why
must I specify a mutex? What I would like to do is have a main controller
thread, and lots of subordinate threads which will all block when they reach
a certain point, and which the main controller thread may then decide to
simultaneously unblock all of. In win32 I would achieve this with
CreateEvent/PulseEvent/WaitForSingleObject. The controller thread would
create some event, all subordinate threads would block on that event (via
WaitForSingleObject), then when the controller wanted them all to unblock it
would PulseEvent.
With SDL I had anticipated that I would use an SDL_cond - i.e. a conditional
variable. But for some reason I am only allowed to have a thread wait on a
conditional after finishing with a mutual exclusion? Why is this?
-Thomas