cds
2.3.2
|
Recursive spin lock. More...
#include <cds/sync/spinlock.h>
Public Types | |
typedef Integral | integral_type |
The integral type. | |
typedef Backoff | backoff_strategy |
The backoff type. | |
Public Member Functions | |
reentrant_spin_lock () noexcept | |
Default constructor initializes spin to free (unlocked) state. | |
reentrant_spin_lock (const reentrant_spin_lock< Integral, Backoff > &) noexcept | |
Dummy copy constructor. More... | |
reentrant_spin_lock (bool bLocked) | |
Construct object in specified state. | |
~reentrant_spin_lock () | |
Dtor. Spin-lock must be unlocked. | |
bool | is_locked () const noexcept |
Checks if the spin is locked. More... | |
bool | try_lock () noexcept(noexcept(std::declval< reentrant_spin_lock >().try_acquire())) |
Try to lock the spin-lock. | |
bool | try_lock (unsigned int nTryCount) noexcept(noexcept(std::declval< reentrant_spin_lock >().try_acquire(nTryCount))) |
Try to lock up to nTryCount attempts. | |
void | lock () noexcept(noexcept(std::declval< reentrant_spin_lock >().acquire())) |
Lock the object waits if it is busy. | |
void | unlock () noexcept |
Unlock the spin-lock. | |
void | change_owner (OS::ThreadId newOwnerId) noexcept |
Change the owner of locked spin-lock. May be called by thread that owns spin-lock. | |
Private Types | |
typedef OS::ThreadId | thread_id |
The type of thread id. | |
Recursive spin lock.
Allows recursive calls: the owner thread may recursive enter to critical section guarded by the spin-lock.
Template parameters:
Integral
one of integral atomic type: unsigned int
, int
, and othersBackoff
backoff strategy. Used when spin lock is locked
|
inlinenoexcept |
Dummy copy constructor.
In theory, spin-lock cannot be copied. However, it is not practical. Therefore, we provide dummy copy constructor that do no copy in fact. The ctor initializes the spin to free (unlocked) state like default ctor.
|
inlinenoexcept |
Checks if the spin is locked.
The spin is locked if lock count > 0 and the current thread is not an owner of the lock. Otherwise (i.e. lock count == 0 or the curren thread owns the spin) the spin is unlocked.