libcruft-util/thread/mutex_win32.cpp
Danny Robson 01094611eb thread: add minimal thread primitives for win32
This allows us to get around the lack of these types under MinGW
2019-06-22 15:46:34 +10:00

40 lines
816 B
C++

#include "mutex.hpp"
using cruft::thread::win32::mutex;
///////////////////////////////////////////////////////////////////////////////
mutex::~mutex ()
{
DeleteCriticalSection (&m_section);
}
///////////////////////////////////////////////////////////////////////////////
void mutex::lock (void)
{
EnterCriticalSection (&m_section);
}
//-----------------------------------------------------------------------------
void mutex::unlock (void)
{
LeaveCriticalSection (&m_section);
}
//-----------------------------------------------------------------------------
bool mutex::try_lock (void)
{
return TryEnterCriticalSection (&m_section);
}
///////////////////////////////////////////////////////////////////////////////
CRITICAL_SECTION&
mutex::native_handle (void)
{
return m_section;
}