1 | #pragma once |
2 | |
3 | #if defined(cafe) |
4 | #include <cafe.h> |
5 | #elif defined(NNSDK) |
6 | #include <nn/os.h> |
7 | #endif |
8 | |
9 | #include <basis/seadTypes.h> |
10 | #include <heap/seadDisposer.h> |
11 | |
12 | namespace sead |
13 | { |
14 | class Heap; |
15 | |
16 | class Mutex : public IDisposer |
17 | { |
18 | public: |
19 | Mutex(); |
20 | explicit Mutex(Heap* disposer_heap); |
21 | Mutex(Heap* disposer_heap, HeapNullOption heap_null_option); |
22 | ~Mutex() override; |
23 | |
24 | Mutex(const Mutex&) = delete; |
25 | Mutex& operator=(const Mutex&) = delete; |
26 | |
27 | void lock(); |
28 | bool tryLock(); |
29 | void unlock(); |
30 | |
31 | // For compatibility with the standard Lockable concept. |
32 | bool try_lock() { return tryLock(); } |
33 | |
34 | #if defined(cafe) |
35 | OSMutex mMutexInner; |
36 | #elif defined(NNSDK) |
37 | nn::os::MutexType mMutexInner; |
38 | #else |
39 | #error "Unknown platform" |
40 | #endif |
41 | }; |
42 | |
43 | } // namespace sead |
44 | |