I'm creating application model with three threads based on while(true)
and a blocking function.
- Event thread - waits for user input, blocked by SDL_WaitEvent
- Socked thread - waits for data from server, blocked by blocking socket.
- Render thread - renders data from buffer, not blocked.
I have a problem with rendering thread - i need a blocking function that will, for example, block until some paint event (defined by me and dispatched in one of other two threads) happens.
But I don't know how blocking functions work. I can, of course, create an sleep()
loop, but such loop has fixed FPS takes resources even if nothing happens (I've already elaborated on that topic here). On the oher side, it does not display data immediatelly. This is not good for GUI application.