carb::tasking::SpinSharedMutex

Defined in carb/tasking/TaskingUtils.h

struct SpinSharedMutex

Spin lock conforming to C++ named requirements of SharedMutex.

Warning

This implementation is non-recursive.

Public Functions

constexpr SpinSharedMutex() = default

Constructor.

inline void lock()

Spins until the shared mutex is exclusive-locked.

Warning

It is an error to lock recursively or shared-lock when exclusive-locked, or vice versa.

inline bool try_lock()

Attempts to exclusive-lock the shared mutex immediately without spinning.

Warning

It is an error to lock recursively or shared-lock when exclusive-locked, or vice versa.

Returns

true if the mutex was exclusive-locked; false if no exclusive lock could be obtained.

inline void unlock()

Unlocks the mutex previously exclusive-locked by this thread/task.

Warning

It is undefined behavior to unlock a mutex that is not owned by the current thread or task.

inline bool try_lock_shared()

Attempts to shared-lock the shared mutex immediately without spinning.

Warning

It is an error to lock recursively or shared-lock when exclusive-locked, or vice versa.

Returns

true if the mutex was shared-locked; false if no shared lock could be obtained.

inline void lock_shared()

Spins until the shared mutex is shared-locked.

Warning

It is an error to lock recursively or shared-lock when exclusive-locked, or vice versa.

inline void unlock_shared()

Unlocks the mutex previously shared-locked by this thread/task.

Warning

It is undefined behavior to unlock a mutex that is not owned by the current thread or task.