summaryrefslogtreecommitdiff
path: root/Runtime/Threading/Mutex.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-25 23:29:21 +0800
committerchai <chaifix@163.com>2021-10-25 23:29:21 +0800
commit7ecf913256fb396e3027aac3318d996a716a52ef (patch)
tree4540835c881a63b665e2a692bf30115fd29e8bb0 /Runtime/Threading/Mutex.cpp
parent0816cd70ca1a213b6ed872bcf3c0bf0912473722 (diff)
+ job system
Diffstat (limited to 'Runtime/Threading/Mutex.cpp')
-rw-r--r--Runtime/Threading/Mutex.cpp25
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