NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ut_lock.h
1#ifndef NW4R_UT_LOCK_H
2#define NW4R_UT_LOCK_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ut/ut_NonCopyable.h>
6
7#include <revolution/OS.h>
8
9namespace nw4r {
10namespace ut {
11namespace detail {
12
13/******************************************************************************
14 *
15 * Mutex lock functions
16 *
17 ******************************************************************************/
18inline void Lock(OSMutex& rMutex) {
19 OSLockMutex(&rMutex);
20}
21inline void Unlock(OSMutex& rMutex) {
22 OSUnlockMutex(&rMutex);
23}
24
25/******************************************************************************
26 *
27 * AutoLock
28 *
29 ******************************************************************************/
30template <typename T> class AutoLock : private NonCopyable {
31public:
32 explicit AutoLock(T& rLockObj) : mLockObj(rLockObj) {
33 Lock(mLockObj);
34 }
35 ~AutoLock() {
36 Unlock(mLockObj);
37 }
38
39private:
40 T& mLockObj; // at 0x0
41};
42
43} // namespace detail
44
45/******************************************************************************
46 *
47 * AutoInterruptLock
48 *
49 ******************************************************************************/
50class AutoInterruptLock : private NonCopyable {
51public:
52 AutoInterruptLock() : mOldState(OSDisableInterrupts()) {}
53 ~AutoInterruptLock() {
54 OSRestoreInterrupts(mOldState);
55 }
56
57private:
58 BOOL mOldState; // at 0x0
59};
60
61} // namespace ut
62} // namespace nw4r
63
64#endif
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4