Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions include/nn/os/os_Mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace nn::os {

// todo: figure out where these go
void InitializeMutex(MutexType*, bool, s32);
void InitializeMutex(MutexType*, bool recursive, s32 lockLevel);
void FinalizeMutex(MutexType*);
void LockMutex(MutexType*);
bool TryLockMutex(MutexType*);
Expand All @@ -20,20 +20,29 @@ class Mutex {
public:
explicit Mutex(bool recursive) { InitializeMutex(&m_Mutex, recursive, 0); }

Mutex(bool, int);
~Mutex();
Mutex(bool recursive, s32 lockLevel) { InitializeMutex(&m_Mutex, recursive, lockLevel); };

~Mutex() { FinalizeMutex(&m_Mutex); }

void Lock() { LockMutex(&m_Mutex); }

bool TryLock();
bool TryLock() { return TryLockMutex(&m_Mutex); }

void Unlock() { UnlockMutex(&m_Mutex); }
bool IsLockedByCurrentThread() const;
void lock();
bool try_lock();
void unlock();
operator MutexType&();
operator const MutexType&() const;
MutexType* GetBase();

bool IsLockedByCurrentThread() const { return IsMutexLockedByCurrentThread(&m_Mutex); };

void lock() { Lock(); }

bool try_lock() { return TryLock(); }

void unlock() { Unlock(); }

operator MutexType&() { return m_Mutex; }

operator const MutexType&() const { return m_Mutex; }

MutexType* GetBase() { return &m_Mutex; }

private:
MutexType m_Mutex;
Expand Down