ThreadLocalValue.h
1.39 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
71
72
73
74
75
76
#pragma once
#include "os/ErrorCodes.h"
#if IL2CPP_SUPPORT_THREADS
#if IL2CPP_THREADS_WIN32
#include "os/Win32/ThreadLocalValueImpl.h"
#elif IL2CPP_THREADS_PTHREAD
#include "os/Posix/ThreadLocalValueImpl.h"
#else
#include "os/ThreadLocalValueImpl.h"
#endif
#endif
namespace il2cpp
{
namespace os
{
class ThreadLocalValueImpl;
class ThreadLocalValue
{
#if IL2CPP_SUPPORT_THREADS
public:
inline ThreadLocalValue()
: m_ThreadLocalValue(new ThreadLocalValueImpl())
{
}
inline ~ThreadLocalValue()
{
delete m_ThreadLocalValue;
}
inline ErrorCode SetValue(void* value)
{
return m_ThreadLocalValue->SetValue(value);
}
inline ErrorCode GetValue(void** value)
{
return m_ThreadLocalValue->GetValue(value);
}
private:
ThreadLocalValueImpl * m_ThreadLocalValue;
#else
public:
inline ThreadLocalValue()
{
}
inline ~ThreadLocalValue()
{
}
inline ErrorCode SetValue(void* value)
{
m_ThreadLocalValue = value;
return kErrorCodeSuccess;
}
inline ErrorCode GetValue(void** value)
{
*value = m_ThreadLocalValue;
return kErrorCodeSuccess;
}
private:
void* m_ThreadLocalValue;
#endif
};
}
}