Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
The scoped locking pattern. More...
#include <spin_rw_mutex.h>
Public Member Functions | |
scoped_lock () | |
Construct lock that has not acquired a mutex. More... | |
scoped_lock (spin_rw_mutex &m, bool write=true) | |
Acquire lock on given mutex. More... | |
~scoped_lock () | |
Release lock (if lock is held). More... | |
void | acquire (spin_rw_mutex &m, bool write=true) |
Acquire lock on given mutex. More... | |
bool | upgrade_to_writer () |
Upgrade reader to become a writer. More... | |
void | release () |
Release lock. More... | |
bool | downgrade_to_reader () |
Downgrade writer to become a reader. More... | |
bool | try_acquire (spin_rw_mutex &m, bool write=true) |
Try acquire lock on given mutex. More... | |
Protected Attributes | |
spin_rw_mutex * | mutex |
The pointer to the current mutex that is held, or NULL if no mutex is held. More... | |
bool | is_writer |
If mutex!=NULL, then is_writer is true if holding a writer lock, false if holding a reader lock. More... | |
Additional Inherited Members | |
![]() | |
no_copy (const no_copy &)=delete | |
no_copy ()=default | |
The scoped locking pattern.
It helps to avoid the common problem of forgetting to release lock. It also nicely provides the "node" for queuing locks.
Definition at line 86 of file spin_rw_mutex.h.
|
inline |
Construct lock that has not acquired a mutex.
Equivalent to zero-initialization of *this.
Definition at line 93 of file spin_rw_mutex.h.
|
inline |
Acquire lock on given mutex.
Definition at line 96 of file spin_rw_mutex.h.
References acquire().
|
inline |
Release lock (if lock is held).
Definition at line 101 of file spin_rw_mutex.h.
References mutex, and release().
|
inline |
Acquire lock on given mutex.
Definition at line 106 of file spin_rw_mutex.h.
References __TBB_ASSERT, tbb::spin_rw_mutex_v3::internal_acquire_reader(), tbb::spin_rw_mutex_v3::internal_acquire_writer(), is_writer, and mutex.
Referenced by scoped_lock().
|
inline |
Downgrade writer to become a reader.
Definition at line 138 of file spin_rw_mutex.h.
References __TBB_ASSERT, tbb::spin_rw_mutex_v3::internal_downgrade(), is_writer, mutex, tbb::spin_rw_mutex_v3::ONE_READER, tbb::spin_rw_mutex_v3::state, and tbb::spin_rw_mutex_v3::WRITER.
|
inline |
Release lock.
Definition at line 124 of file spin_rw_mutex.h.
References __TBB_ASSERT, __TBB_AtomicAND(), __TBB_FetchAndAddWrelease, tbb::spin_rw_mutex_v3::internal_release_reader(), tbb::spin_rw_mutex_v3::internal_release_writer(), is_writer, mutex, tbb::spin_rw_mutex_v3::ONE_READER, tbb::spin_rw_mutex_v3::READERS, and tbb::spin_rw_mutex_v3::state.
Referenced by ~scoped_lock().
|
inline |
Try acquire lock on given mutex.
Definition at line 151 of file spin_rw_mutex.h.
References __TBB_ASSERT, tbb::spin_rw_mutex_v3::internal_try_acquire_reader(), tbb::spin_rw_mutex_v3::internal_try_acquire_writer(), is_writer, and mutex.
|
inline |
Upgrade reader to become a writer.
Returns whether the upgrade happened without releasing and re-acquiring the lock
Definition at line 116 of file spin_rw_mutex.h.
References __TBB_ASSERT, tbb::spin_rw_mutex_v3::internal_upgrade(), is_writer, and mutex.
|
protected |
If mutex!=NULL, then is_writer is true if holding a writer lock, false if holding a reader lock.
Not defined if not holding a lock.
Definition at line 169 of file spin_rw_mutex.h.
Referenced by acquire(), downgrade_to_reader(), release(), try_acquire(), and upgrade_to_writer().
|
protected |
The pointer to the current mutex that is held, or NULL if no mutex is held.
Definition at line 165 of file spin_rw_mutex.h.
Referenced by acquire(), downgrade_to_reader(), release(), try_acquire(), upgrade_to_writer(), and ~scoped_lock().