summaryrefslogtreecommitdiff
path: root/Client/Source/Threading/Mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Source/Threading/Mutex.cpp')
-rw-r--r--Client/Source/Threading/Mutex.cpp27
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