ReaderWriterLockImpl.h
1.4 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
65
66
67
68
69
70
#pragma once
#include "il2cpp-config.h"
#if IL2CPP_THREADS_PTHREAD && !RUNTIME_TINY
#include <pthread.h>
namespace il2cpp
{
namespace os
{
class ReaderWriterLockImpl
{
public:
ReaderWriterLockImpl()
{
int result = pthread_rwlock_init(&m_Lock, NULL);
NO_UNUSED_WARNING(result);
IL2CPP_ASSERT(result == 0);
}
~ReaderWriterLockImpl()
{
int result = pthread_rwlock_destroy(&m_Lock);
NO_UNUSED_WARNING(result);
IL2CPP_ASSERT(result == 0);
}
void LockExclusive()
{
int result = pthread_rwlock_wrlock(&m_Lock);
NO_UNUSED_WARNING(result);
IL2CPP_ASSERT(result == 0);
}
void LockShared()
{
int result = pthread_rwlock_rdlock(&m_Lock);
NO_UNUSED_WARNING(result);
IL2CPP_ASSERT(result == 0);
}
void ReleaseExclusive()
{
int result = pthread_rwlock_unlock(&m_Lock);
NO_UNUSED_WARNING(result);
IL2CPP_ASSERT(result == 0);
}
void ReleaseShared()
{
int result = pthread_rwlock_unlock(&m_Lock);
NO_UNUSED_WARNING(result);
IL2CPP_ASSERT(result == 0);
}
pthread_rwlock_t* GetOSHandle()
{
return &m_Lock;
}
private:
pthread_rwlock_t m_Lock;
};
}
}
#endif