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
5namespace nw { namespace ut {
6
7class Mutex
8{
9public:
11 : m_IsIntialized(false)
12 {
13 }
14
16 {
17 }
18
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
58private:
61};
62static_assert(sizeof(Mutex) == 0x30, "nw::ut::Mutex size mismatch");
63
64} }
Definition ut_Mutex.h:8
OSMutex m_Lock
Definition ut_Mutex.h:59
Mutex()
Definition ut_Mutex.h:10
bool TryLock()
Definition ut_Mutex.h:39
~Mutex()
Definition ut_Mutex.h:15
void Initialize()
Definition ut_Mutex.h:19
void Lock()
Definition ut_Mutex.h:33
void Finalize()
Definition ut_Mutex.h:28
bool m_IsIntialized
Definition ut_Mutex.h:60
void Unlock()
Definition ut_Mutex.h:45
Definition ut_CriticalSection.h:6
Definition math_Constant.cpp:5