diff options
Diffstat (limited to 'Runtime/Threading/Mutex.cpp')
-rw-r--r-- | Runtime/Threading/Mutex.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Runtime/Threading/Mutex.cpp b/Runtime/Threading/Mutex.cpp new file mode 100644 index 0000000..eabe48d --- /dev/null +++ b/Runtime/Threading/Mutex.cpp @@ -0,0 +1,25 @@ +#include "Thread.h" +#include "Mutex.h" + +Mutex::Mutex() +{ + m_Handle = ::CreateMutex(NULL, FALSE, NULL); + if (!m_Handle) + throw ThreadException("Cant use win32 mutex."); +} + +Mutex::~Mutex() +{ + ::CloseHandle(m_Handle); + m_Handle = NULL; +} + +void Mutex::Lock() +{ + ::WaitForSingleObject(m_Handle, (~(uint32)0)); +} + +void Mutex::Unlock() +{ + ::ReleaseMutex(m_Handle); +}
\ No newline at end of file |