17 INLINE ConditionVarFullWin32Impl::
18 ConditionVarFullWin32Impl(MutexWin32Impl &mutex) {
19 _external_mutex = &mutex._lock;
22 _event_signal = CreateEvent(
nullptr,
false,
false,
nullptr);
23 _event_broadcast = CreateEvent(
nullptr,
true,
false,
nullptr);
31 INLINE ConditionVarFullWin32Impl::
32 ~ConditionVarFullWin32Impl() {
33 CloseHandle(_event_signal);
34 CloseHandle(_event_broadcast);
40 INLINE
void ConditionVarFullWin32Impl::
47 LeaveCriticalSection(_external_mutex);
51 int result = WaitForMultipleObjects(2, &_event_signal, FALSE, INFINITE);
54 bool last_waiter = (result == WAIT_OBJECT_0 + 1 && !nonzero);
60 ResetEvent(_event_broadcast);
64 EnterCriticalSection(_external_mutex);
70 INLINE
void ConditionVarFullWin32Impl::
71 wait(
double timeout) {
77 LeaveCriticalSection(_external_mutex);
81 int result = WaitForMultipleObjects(2, &_event_signal, FALSE, (DWORD)(timeout * 1000.0));
84 bool last_waiter = (result == WAIT_OBJECT_0 + 1 && !nonzero);
90 ResetEvent(_event_broadcast);
94 EnterCriticalSection(_external_mutex);
100 INLINE
void ConditionVarFullWin32Impl::
105 SetEvent(_event_signal);
112 INLINE
void ConditionVarFullWin32Impl::
117 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.