SuperMarioOdysseyOnline/include/sead/thread/seadSpinLock.h
2022-06-16 14:33:18 -07:00

29 lines
445 B
C++

#pragma once
#include "basis/seadTypes.h"
#include "thread/seadAtomic.h"
namespace sead
{
class Thread;
class SpinLock
{
public:
SpinLock();
~SpinLock();
SpinLock(const SpinLock&) = delete;
SpinLock& operator=(const SpinLock&) = delete;
void lock();
bool tryLock();
void unlock();
bool try_lock() { return tryLock(); }
private:
Atomic<Thread*> mOwnerThread;
u32 mCount = 0;
};
} // namespace sead