Blocking 2nd thread until event is received in main

I’m developing a C++ program in Visual Studio using SDL. I’m porting an older program that used the native Windows API. In it, there’s two threads, the main thread containing the message loop, and a second thread that needs to block waiting for certain messages. The app uses CreateEvent and SetEvent to signal an event, and WaitForSingleObject on the event in the second thread to wait for an event. Now I’m a bit at loss how to port this to SDL. I’ve seen the example with SDL_CondWait, but this seems a bit convoluted, and not quite semantically what I’m after. Is there another way to implement a blocking wait with SDL?

I use a semaphore, with SDL_SemWait() substituting for WaitForSingleObject() and SDL_SemPost() substituting for SetEvent().

1 Like

I looked into semaphores, but didn’t think of using them like that. Thanks for the suggestion!