Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
Fast, unfair, spinning reader-writer lock with backoff and writer-preference. More...
#include <spin_rw_mutex.h>
Classes | |
class | scoped_lock |
The scoped locking pattern. More... | |
Public Member Functions | |
spin_rw_mutex_v3 () | |
Construct unacquired mutex. More... | |
void | lock () |
Acquire writer lock. More... | |
bool | try_lock () |
Try acquiring writer lock (non-blocking) More... | |
void | unlock () |
Release lock. More... | |
void | lock_read () |
Acquire reader lock. More... | |
bool | try_lock_read () |
Try acquiring reader lock (non-blocking) More... | |
Static Public Attributes | |
static const bool | is_rw_mutex = true |
static const bool | is_recursive_mutex = false |
static const bool | is_fair_mutex = false |
Protected Types | |
typedef intptr_t | state_t |
Protected Attributes | |
state_t | state |
State of lock. More... | |
Static Protected Attributes | |
static const state_t | WRITER = 1 |
static const state_t | WRITER_PENDING = 2 |
static const state_t | READERS = ~(WRITER | WRITER_PENDING) |
static const state_t | ONE_READER = 4 |
static const state_t | BUSY = WRITER | READERS |
Private Member Functions | |
bool __TBB_EXPORTED_METHOD | internal_acquire_writer () |
Internal acquire write lock. More... | |
void __TBB_EXPORTED_METHOD | internal_release_writer () |
Out of line code for releasing a write lock. More... | |
void __TBB_EXPORTED_METHOD | internal_acquire_reader () |
Internal acquire read lock. More... | |
bool __TBB_EXPORTED_METHOD | internal_upgrade () |
Internal upgrade reader to become a writer. More... | |
void __TBB_EXPORTED_METHOD | internal_downgrade () |
Out of line code for downgrading a writer to a reader. More... | |
void __TBB_EXPORTED_METHOD | internal_release_reader () |
Internal release read lock. More... | |
bool __TBB_EXPORTED_METHOD | internal_try_acquire_writer () |
Internal try_acquire write lock. More... | |
bool __TBB_EXPORTED_METHOD | internal_try_acquire_reader () |
Internal try_acquire read lock. More... | |
void __TBB_EXPORTED_METHOD | internal_construct () |
Fast, unfair, spinning reader-writer lock with backoff and writer-preference.
Definition at line 38 of file spin_rw_mutex.h.
|
protected |
Definition at line 207 of file spin_rw_mutex.h.
|
inline |
Construct unacquired mutex.
Definition at line 70 of file spin_rw_mutex.h.
References internal_construct().
|
private |
Internal acquire read lock.
Acquire read lock on given mutex.
Definition at line 62 of file spin_rw_mutex.cpp.
References __TBB_ASSERT, ITT_NOTIFY, ONE_READER, tbb::internal::atomic_backoff::pause(), READERS, s, state, WRITER, and WRITER_PENDING.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::acquire(), and lock_read().
|
private |
Internal acquire write lock.
Acquire write lock on the given mutex.
Definition at line 37 of file spin_rw_mutex.cpp.
References __TBB_AtomicOR(), BUSY, tbb::CAS(), ITT_NOTIFY, tbb::internal::atomic_backoff::pause(), s, state, WRITER, and WRITER_PENDING.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::acquire(), internal_upgrade(), and lock().
|
private |
Definition at line 152 of file spin_rw_mutex.cpp.
References _T, and ITT_SYNC_CREATE.
Referenced by spin_rw_mutex_v3().
|
private |
Out of line code for downgrading a writer to a reader.
Downgrade writer to a reader.
This code has debug checking and instrumentation for Intel(R) Thread Checker and Intel(R) Thread Profiler.
Definition at line 108 of file spin_rw_mutex.cpp.
References __TBB_ASSERT, ITT_NOTIFY, ONE_READER, READERS, state, sync_releasing, and WRITER.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::downgrade_to_reader().
|
private |
Internal release read lock.
Release read lock on the given mutex.
Definition at line 115 of file spin_rw_mutex.cpp.
References __TBB_ASSERT, __TBB_FetchAndAddWrelease, ITT_NOTIFY, ONE_READER, READERS, state, and sync_releasing.
Referenced by internal_upgrade(), tbb::spin_rw_mutex_v3::scoped_lock::release(), and unlock().
|
private |
Out of line code for releasing a write lock.
Release writer lock on the given mutex.
This code has debug checking and instrumentation for Intel(R) Thread Checker and Intel(R) Thread Profiler.
Definition at line 55 of file spin_rw_mutex.cpp.
References __TBB_AtomicAND(), ITT_NOTIFY, READERS, state, and sync_releasing.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::release(), and unlock().
|
private |
Internal try_acquire read lock.
Try to acquire read lock on the given mutex.
Definition at line 136 of file spin_rw_mutex.cpp.
References ITT_NOTIFY, ONE_READER, s, state, WRITER, and WRITER_PENDING.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::try_acquire(), and try_lock_read().
|
private |
Internal try_acquire write lock.
Try to acquire write lock on the given mutex.
Definition at line 123 of file spin_rw_mutex.cpp.
References BUSY, tbb::CAS(), ITT_NOTIFY, s, state, and WRITER.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::try_acquire(), and try_lock().
|
private |
Internal upgrade reader to become a writer.
Upgrade reader to become a writer.
Returns whether the upgrade happened without releasing and re-acquiring the lock
Definition at line 82 of file spin_rw_mutex.cpp.
References __TBB_ASSERT, tbb::CAS(), internal_acquire_writer(), internal_release_reader(), ITT_NOTIFY, ONE_READER, tbb::internal::atomic_backoff::pause(), READERS, s, state, WRITER, and WRITER_PENDING.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::upgrade_to_writer().
|
inline |
Acquire writer lock.
Definition at line 180 of file spin_rw_mutex.h.
References internal_acquire_writer().
Referenced by tbb::internal::market::adjust_demand(), and tbb::internal::market::try_destroy_arena().
|
inline |
Acquire reader lock.
Definition at line 200 of file spin_rw_mutex.h.
References internal_acquire_reader().
|
inline |
Try acquiring writer lock (non-blocking)
Return true if lock acquired; false otherwise.
Definition at line 184 of file spin_rw_mutex.h.
References internal_try_acquire_writer().
|
inline |
Try acquiring reader lock (non-blocking)
Return true if reader lock acquired; false otherwise.
Definition at line 204 of file spin_rw_mutex.h.
References internal_try_acquire_reader().
|
inline |
Release lock.
Definition at line 187 of file spin_rw_mutex.h.
References __TBB_AtomicAND(), __TBB_FetchAndAddWrelease, internal_release_reader(), internal_release_writer(), ONE_READER, READERS, state, and WRITER.
Referenced by tbb::internal::market::adjust_demand(), and tbb::internal::market::try_destroy_arena().
Definition at line 212 of file spin_rw_mutex.h.
Referenced by internal_acquire_writer(), and internal_try_acquire_writer().
|
static |
Definition at line 175 of file spin_rw_mutex.h.
|
static |
Definition at line 174 of file spin_rw_mutex.h.
|
static |
Definition at line 173 of file spin_rw_mutex.h.
|
staticprotected |
Definition at line 211 of file spin_rw_mutex.h.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::downgrade_to_reader(), internal_acquire_reader(), internal_downgrade(), internal_release_reader(), internal_try_acquire_reader(), internal_upgrade(), tbb::spin_rw_mutex_v3::scoped_lock::release(), and unlock().
|
staticprotected |
Definition at line 210 of file spin_rw_mutex.h.
Referenced by internal_acquire_reader(), internal_downgrade(), internal_release_reader(), internal_release_writer(), internal_upgrade(), tbb::spin_rw_mutex_v3::scoped_lock::release(), and unlock().
|
protected |
State of lock.
Bit 0 = writer is holding lock Bit 1 = request by a writer to acquire lock (hint to readers to wait) Bit 2..N = number of readers holding lock
Definition at line 217 of file spin_rw_mutex.h.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::downgrade_to_reader(), internal_acquire_reader(), internal_acquire_writer(), internal_downgrade(), internal_release_reader(), internal_release_writer(), internal_try_acquire_reader(), internal_try_acquire_writer(), internal_upgrade(), tbb::spin_rw_mutex_v3::scoped_lock::release(), and unlock().
|
staticprotected |
Definition at line 208 of file spin_rw_mutex.h.
Referenced by tbb::spin_rw_mutex_v3::scoped_lock::downgrade_to_reader(), internal_acquire_reader(), internal_acquire_writer(), internal_downgrade(), internal_try_acquire_reader(), internal_try_acquire_writer(), internal_upgrade(), and unlock().
|
staticprotected |
Definition at line 209 of file spin_rw_mutex.h.
Referenced by internal_acquire_reader(), internal_acquire_writer(), internal_try_acquire_reader(), and internal_upgrade().