openMSX
CondVar.cc
Go to the documentation of this file.
1 #include "CondVar.hh"
2 #include <SDL.h>
3 
4 namespace openmsx {
5 
7 {
8  mutex = SDL_CreateMutex();
9  cond = SDL_CreateCond();
10 }
11 
13 {
14  SDL_DestroyCond(cond);
15  SDL_DestroyMutex(mutex);
16 }
17 
19 {
20  SDL_mutexP(mutex);
21  SDL_CondWait(cond, mutex);
22 }
23 
24 bool CondVar::waitTimeout(unsigned us)
25 {
26  SDL_mutexP(mutex);
27  int result = SDL_CondWaitTimeout(cond, mutex, us / 1000);
28  return result == SDL_MUTEX_TIMEDOUT;
29 }
30 
32 {
33  SDL_CondSignal(cond);
34 }
35 
37 {
38  SDL_CondBroadcast(cond);
39 }
40 
41 } // namespace openmsx