5 //std::cout << "Create " << _name << "." << std::endl;
\r
6 _mutex = new Mutex();
\r
7 _condition = new Condition(_mutex);
\r
8 _waitMutex = new Mutex();
\r
9 _waitCondition = new Condition(_waitMutex);
\r
10 _pendingWait = false;
\r
14 Event::Event(std::string name) {
\r
15 _name = "Event " + name;
\r
16 //std::cout << "Create " << _name << "." << std::endl;
\r
17 _mutex = new Mutex();
\r
18 _condition = new Condition(_mutex);
\r
19 _waitMutex = new Mutex();
\r
20 _waitCondition = new Condition(_waitMutex);
\r
21 _pendingWait = false;
\r
26 //std::cout << "Delete " << _name << "." << std::endl;
\r
28 delete _waitCondition;
\r
31 //std::cout << "Deleted " << _name << "." << std::endl;
\r
35 void Event::notify() {
\r
37 _condition->notify();
\r
42 void Event::notifyAll() {
\r
44 _condition->notifyAll();
\r
49 void Event::wait() {
\r
51 _pendingWait = true;
\r
53 _waitCondition->notify();
\r
54 _waitMutex->unlock();
\r
56 _pendingWait = false;
\r
61 void Event::notifyAfterWait() {
\r
64 if (!_pendingWait) {
\r
67 _waitCondition->wait();
\r
69 _waitMutex->unlock();
\r
71 _condition->notify();
\r