openMSX
Main Page
Namespaces
Classes
Files
File List
File Members
thread
CondVar.cc
Go to the documentation of this file.
1
#include "
CondVar.hh
"
2
#include <SDL.h>
3
4
namespace
openmsx {
5
6
CondVar::CondVar
()
7
{
8
mutex = SDL_CreateMutex();
9
cond = SDL_CreateCond();
10
}
11
12
CondVar::~CondVar
()
13
{
14
SDL_DestroyCond(cond);
15
SDL_DestroyMutex(mutex);
16
}
17
18
void
CondVar::wait
()
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
31
void
CondVar::signal
()
32
{
33
SDL_CondSignal(cond);
34
}
35
36
void
CondVar::signalAll
()
37
{
38
SDL_CondBroadcast(cond);
39
}
40
41
}
// namespace openmsx
Generated on Sat May 25 2013 10:17:13 for openMSX by
1.8.1.2