summaryrefslogtreecommitdiff
path: root/Runtime/Threading/Mutex.cpp
blob: 6be162f67d0908d2109cea82dcf9f72dd106c8ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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::LockSelf()
{
	::WaitForSingleObject(m_Handle, (~(uint32)0));
}

void Mutex::UnlockSelf()
{
	::ReleaseMutex(m_Handle);
}