21 INLINE ConditionVarFullWin32Impl::
22 ConditionVarFullWin32Impl(MutexWin32Impl &mutex) {
23 _external_mutex = &mutex._lock;
26 _event_signal = CreateEvent(NULL,
false,
false, NULL);
27 _event_broadcast = CreateEvent(NULL,
true,
false, NULL);
37 INLINE ConditionVarFullWin32Impl::
38 ~ConditionVarFullWin32Impl() {
39 CloseHandle(_event_signal);
40 CloseHandle(_event_broadcast);
48 INLINE
void ConditionVarFullWin32Impl::
55 LeaveCriticalSection(_external_mutex);
59 int result = WaitForMultipleObjects(2, &_event_signal, FALSE, INFINITE);
62 bool last_waiter = (result == WAIT_OBJECT_0 + 1 && !nonzero);
68 ResetEvent(_event_broadcast);
72 EnterCriticalSection(_external_mutex);
80 INLINE
void ConditionVarFullWin32Impl::
81 wait(
double timeout) {
87 LeaveCriticalSection(_external_mutex);
91 int result = WaitForMultipleObjects(2, &_event_signal, FALSE, (DWORD)(timeout * 1000.0));
94 bool last_waiter = (result == WAIT_OBJECT_0 + 1 && !nonzero);
100 ResetEvent(_event_broadcast);
104 EnterCriticalSection(_external_mutex);
112 INLINE
void ConditionVarFullWin32Impl::
117 SetEvent(_event_signal);
126 INLINE
void ConditionVarFullWin32Impl::
131 SetEvent(_event_broadcast);
static void inc(Integer &var)
Atomically increments the indicated variable.
static bool dec(Integer &var)
Atomically decrements the indicated variable and returns true if the new value is nonzero...
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.