12#include <bits/pthreadtypes.h>
49 mutable pthread_cond_t
cond;
64 int res = pthread_mutex_init(&this->
mutex,
nullptr);
68 res = pthread_cond_init(&this->
cond,
nullptr);
78 int res = pthread_cond_destroy(&this->
cond);
80 res = pthread_mutex_destroy(&this->
mutex);
83 this->
mutex = ev.mutex;
87 ev.mutex = pthread_mutex_t{};
88 ev.cond = pthread_cond_t{};
98 int res = pthread_cond_destroy(&this->
cond);
100 res = pthread_mutex_destroy(&this->
mutex);
110 pthread_mutex_lock(&this->
mutex);
114 pthread_cond_broadcast(&this->
cond);
119 pthread_cond_signal(&this->
cond);
121 pthread_mutex_unlock(&this->
mutex);
130 pthread_mutex_lock(&this->
mutex);
149 int res = pthread_cond_wait(&this->
cond, &this->
mutex);
153 pthread_mutex_unlock(&this->
mutex);
162 bool timeOutOccured =
false;
163 pthread_mutex_lock(&this->
mutex);
182 timeSpec.tv_sec = ms / 1000;
183 timeSpec.tv_nsec = (ms - timeSpec.tv_sec * 1000) * 1000000;
185 int res = pthread_cond_timedwait(&this->
cond, &this->
mutex, &timeSpec);
187 if (ETIMEDOUT == res)
189 timeOutOccured =
true;
192 }
while(!locked && !timeOutOccured);
193 pthread_mutex_unlock(&this->
mutex);
194 return !timeOutOccured;
212 pthread_mutex_lock(&this->
mutex);
214 pthread_mutex_unlock(&this->
mutex);
Linux implementation of Event.
Definition linuxevent.h:18
void Reset()
manually reset the event
Definition linuxevent.h:210
bool WaitTimeout(int ms) const
wait for the event with timeout in millisecs, resets the event
Definition linuxevent.h:160
bool manualReset
Definition linuxevent.h:51
EventStatus
Definition linuxevent.h:42
@ SIGNAL_ALL
Definition linuxevent.h:45
@ SIGNAL_ONE
Definition linuxevent.h:44
@ SIGNAL_NONE
Definition linuxevent.h:43
pthread_mutex_t mutex
Definition linuxevent.h:48
bool Peek() const
check if event is signaled
Definition linuxevent.h:201
void Signal()
signal the event
Definition linuxevent.h:108
void Wait() const
wait for the event to become signalled, resets the event
Definition linuxevent.h:128
pthread_cond_t cond
Definition linuxevent.h:49
bool IsManual() const
Returns true if event is manually reset.
Definition linuxevent.h:221
~LinuxEvent()
destructor
Definition linuxevent.h:96
volatile EventStatus status
Definition linuxevent.h:52
LinuxEvent(bool manualReset=false)
constructor
Definition linuxevent.h:59
#define n_assert(exp)
Definition debug.h:50
Definition linuxcompletioncounter.h:15