43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#include "condition_variable_win32.hpp"
|
|
|
|
#include <synchapi.h>
|
|
|
|
using cruft::thread::win32::condition_variable;
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
condition_variable::condition_variable ()
|
|
: m_native (CONDITION_VARIABLE_INIT)
|
|
{
|
|
InitializeConditionVariable (&m_native);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
condition_variable::~condition_variable ()
|
|
{ ; }
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void
|
|
condition_variable::wait (std::unique_lock<cruft::thread::mutex> &lock)
|
|
{
|
|
SleepConditionVariableCS (
|
|
&m_native, &lock.mutex ()->native_handle (), INFINITE
|
|
);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void condition_variable::notify_one (void) noexcept
|
|
{
|
|
WakeConditionVariable (&m_native);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void condition_variable::notify_all () noexcept
|
|
{
|
|
WakeAllConditionVariable (&m_native);
|
|
}
|