diff options
author | chai <chaifix@163.com> | 2021-12-13 00:07:19 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-12-13 00:07:19 +0800 |
commit | 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 (patch) | |
tree | b2c7b0a868f18159dbc43d8954e1bd7668549a88 /Client/Source/Threading/Mutex.cpp |
+init
Diffstat (limited to 'Client/Source/Threading/Mutex.cpp')
-rw-r--r-- | Client/Source/Threading/Mutex.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Client/Source/Threading/Mutex.cpp b/Client/Source/Threading/Mutex.cpp new file mode 100644 index 0000000..cda7e89 --- /dev/null +++ b/Client/Source/Threading/Mutex.cpp @@ -0,0 +1,27 @@ +#include "Thread.h" +#include "Mutex.h" + +#include "../Utilities/Type.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::LockSelf() +{ + ::WaitForSingleObject(m_Handle, (~(uint32)0)); +} + +void Mutex::UnlockSelf() +{ + ::ReleaseMutex(m_Handle); +}
\ No newline at end of file |