MutexImpl.h
1.1 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#if IL2CPP_THREADS_WIN32
#include "os/ErrorCodes.h"
#include "os/WaitStatus.h"
#include "utils/NonCopyable.h"
#include "WindowsHeaders.h"
namespace il2cpp
{
namespace os
{
class MutexImpl : public il2cpp::utils::NonCopyable
{
public:
MutexImpl();
~MutexImpl();
void Lock(bool interruptible);
bool TryLock(uint32_t milliseconds, bool interruptible);
void Unlock();
void* GetOSHandle();
private:
HANDLE m_MutexHandle;
};
class FastMutexImpl
{
public:
FastMutexImpl()
{
InitializeCriticalSection(&m_CritialSection);
}
~FastMutexImpl()
{
DeleteCriticalSection(&m_CritialSection);
}
void Lock()
{
EnterCriticalSection(&m_CritialSection);
}
void Unlock()
{
LeaveCriticalSection(&m_CritialSection);
}
CRITICAL_SECTION* GetOSHandle()
{
return &m_CritialSection;
}
private:
CRITICAL_SECTION m_CritialSection;
};
}
}
#endif