mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-24 12:15:16 +00:00
29 lines
445 B
C++
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
|