CTR Pia
4.11.3
Game Communication Engine
Main Page
Namespace List
Class List
Class Index
Related Pages
Search Results
common_CriticalSection.h
1
/*---------------------------------------------------------------------------*
2
Project: Pia
3
File: common_CriticalSection.h
4
5
Copyright Nintendo. All rights reserved.
6
7
These coded instructions, statements, and computer programs contain
8
proprietary information of Nintendo of America Inc. and/or Nintendo
9
Company Ltd., and are protected by Federal copyright law. They may
10
not be disclosed to third parties or copied or duplicated in any form,
11
in whole or in part, without the prior written consent of Nintendo.
12
*---------------------------------------------------------------------------*/
13
14
15
#pragma once
16
17
#include <pia/definitions.h>
18
#include <pia/common/common_RootObject.h>
19
20
#if NN_PIA_CAFE
21
#include <sdk_ver.h>
22
23
#if CAFE_OS_SDK_VERSION >= 21002
24
#define NN_PIA_USE_FAST_MUTEX 1
25
#else
26
#define NN_PIA_USE_FAST_MUTEX 0
27
#endif
28
#endif
29
30
#define PIA_CRITICAL_SECTION_LOCK_CHECKER_ENABLE NN_PIA_UNDER_DEVELOP
31
32
33
namespace
nn
34
{
35
namespace
pia
36
{
37
namespace
common
38
{
39
40
/*!
41
@cond PRIVATE
42
@brief Wrapper for <tt>CriticalSection</tt>.
43
*/
44
class
CriticalSection :
public
common::RootObject
45
{
46
public
:
47
/*!
48
@brief Constructor.
49
@param[in] lockOrder Specifies the lock order. Specify the value of <tt>CriticalSectionLockChecker::LockOrder</tt>.
50
*/
51
explicit
CriticalSection(
int
lockOrder = -1);
52
53
54
/*!
55
@brief Destructor.
56
*/
57
~CriticalSection();
58
59
60
/*!
61
@brief Locks the critical section.
62
*/
63
void
Lock();
64
65
66
/*!
67
@brief Tries to lock the critical section.
68
@return Returns <tt>true</tt> if successful.
69
*/
70
bool
TryLock();
71
72
73
/*!
74
@brief Unlocks the critical section.
75
*/
76
void
Unlock();
77
78
79
/*!
80
@brief Prints information useful for debugging.
81
82
@param[in] flag Specifies the bitwise OR of trace flags. For more information, see the <tt>@ref TraceFlag</tt> type.
83
*/
84
void
Trace(u64 flag)
const
;
85
86
87
/*!
88
@brief Gets the lock order.
89
*/
90
#if PIA_CRITICAL_SECTION_LOCK_CHECKER_ENABLE
91
int
GetLockOrder()
const
92
{
93
return
m_LockOrder;
94
}
95
#endif
96
97
98
private
:
99
#if NN_PIA_CTR
100
nn::os::CriticalSection m_CriticalSection;
101
#elif NN_PIA_WIN || NN_PIA_NIN_WIN
102
CRITICAL_SECTION m_CriticalSection;
103
#elif NN_PIA_CAFE
104
#if NN_PIA_USE_FAST_MUTEX
105
OSFastMutex m_FastMutex;
106
#else
107
OSMutex m_Mutex;
108
#endif
109
#else
110
#error "Invalid platform"
111
#endif
112
113
#if PIA_CRITICAL_SECTION_LOCK_CHECKER_ENABLE
114
int
m_LockOrder;
115
#endif
116
};
117
//! @endcond
118
}
119
}
120
}
// end of namespace nn::pia::common
nn
Definition:
assert.h:115
include
pia
common
common_CriticalSection.h
© 2013–2017 Nintendo. All rights reserved. All company and product names in this document are the trademarks or registered trademarks of their respective companies.