NW4F Sys
Loading...
Searching...
No Matches
ut_Mutex.h
Go to the documentation of this file.
1
#
pragma
once
2
3
#
include
<
cafe
/
os
/
OSMutex
.
h
>
4
5
namespace
nw
{
namespace
ut
{
6
7
class
Mutex
8
{
9
public
:
10
Mutex
()
11
:
m_IsIntialized
(
false
)
12
{
13
}
14
15
~
Mutex
()
16
{
17
}
18
19
void
Initialize
()
20
{
21
if
(!
m_IsIntialized
)
22
{
23
m_IsIntialized
=
true
;
24
OSInitMutex(&m_Lock);
25
}
26
}
27
28
void
Finalize
()
29
{
30
m_IsIntialized
=
false
;
31
}
32
33
void
Lock
()
34
{
35
// NW_ASSERT(m_IsIntialized);
36
OSLockMutex(&m_Lock);
37
}
38
39
bool
TryLock
()
40
{
41
// NW_ASSERT(m_IsIntialized);
42
return
OSTryLockMutex(&m_Lock) !=
false
;
43
}
44
45
void
Unlock
()
46
{
47
// NW_ASSERT(m_IsIntialized);
48
OSUnlockMutex(&m_Lock);
49
}
50
51
// TODO
52
// void WaitCond(OSCond& cond)
53
// {
54
// // NW_ASSERT(m_IsIntialized);
55
// OSWaitCond(&cond, &m_Lock);
56
// }
57
58
private
:
59
OSMutex
m_Lock
;
60
bool
m_IsIntialized
;
61
};
62
static_assert
(
sizeof
(
Mutex
) == 0x30,
"nw::ut::Mutex size mismatch"
);
63
64
} }
nw::ut::Mutex
Definition
ut_Mutex.h:8
nw::ut::Mutex::m_Lock
OSMutex m_Lock
Definition
ut_Mutex.h:59
nw::ut::Mutex::Mutex
Mutex()
Definition
ut_Mutex.h:10
nw::ut::Mutex::TryLock
bool TryLock()
Definition
ut_Mutex.h:39
nw::ut::Mutex::~Mutex
~Mutex()
Definition
ut_Mutex.h:15
nw::ut::Mutex::Initialize
void Initialize()
Definition
ut_Mutex.h:19
nw::ut::Mutex::Lock
void Lock()
Definition
ut_Mutex.h:33
nw::ut::Mutex::Finalize
void Finalize()
Definition
ut_Mutex.h:28
nw::ut::Mutex::m_IsIntialized
bool m_IsIntialized
Definition
ut_Mutex.h:60
nw::ut::Mutex::Unlock
void Unlock()
Definition
ut_Mutex.h:45
nw::ut
Definition
ut_CriticalSection.h:6
nw
Definition
math_Constant.cpp:5
include
nw
ut
os
ut_Mutex.h
Generated by
1.14.0