carb::thread::detail::SpinlockImpl
Defined in carb/thread/Spinlock.h
- 
template<class RecursionPolicy>
 class SpinlockImpl
- Spinlock and RecursiveSpinlock are locking primitives that never enter the kernel to wait. - This class meets Cpp17BasicLockable and Cpp17Lockable named requirements. - Note - Do not use SpinlockImpl directly; instead use Spinlock or RecursiveSpinlock. - Warning - Using Spinlock is generally discouraged and can lead to worse performance than using carb::thread::mutex or another synchronization primitive that can wait. - Public Functions - 
constexpr SpinlockImpl() = default
- Constructor. 
 - 
~SpinlockImpl() = default
- Destructor. 
 - 
inline void lock()
- Locks the spinlock, spinning the current thread until it becomes available. - If not called from RecursiveSpinlock and the calling thread already owns the lock, - std::terminate()is called. The calling thread must call unlock() at a later time to release the lock.
 - 
inline void unlock()
- Unlocks the spinlock. - Warning - std::terminate()is called if the calling thread does not own the spinlock.
 - 
inline bool try_lock()
- Attempts to immediately lock the spinlock. - If not called from RecursiveSpinlock and the calling thread already owns the lock, - std::terminate()is called.- Returns
- trueif the spinlock was available and the lock was taken by the calling thread (unlock() must be called from the calling thread at a later time to release the lock);- falseif the spinlock could not be locked by the calling thread.
 
 - 
inline bool isLockedByThisThread() const
- Returns true if the calling thread owns this spinlock. - Returns
- trueif the calling thread owns this spinlock;- falseotherwise.
 
 
- 
constexpr SpinlockImpl() = default