|
Zero
0.1.0
|
Shore read-write lock:: many-reader/one-writer spin lock. More...
#include <latches.h>
Public Types | |
| enum | rwmode_t { NONE = 0, WRITER = 0x1, READER = 0x2 } |
Public Member Functions | |
| mcs_rwlock () | |
| ~mcs_rwlock () | |
| rwmode_t | mode () const |
| Return the mode in which this lock is held by anyone. More... | |
| bool | is_locked () const |
| True if locked in any mode. More... | |
| int | num_holders () const |
| 1 if held in write mode, else it's the number of readers More... | |
| bool | has_reader () const |
| True iff has one or more readers. More... | |
| bool | has_writer () const |
| True iff has a writer (never more than 1) More... | |
| bool | attempt_read () |
| True if success. More... | |
| void | acquire_read () |
| Wait (spin) until acquired. More... | |
| void | release_read () |
| This thread had better hold the lock in read mode. More... | |
| bool | attempt_write () |
| True if success. More... | |
| void | acquire_write () |
| Wait (spin) until acquired. More... | |
| void | release_write () |
| This thread had better hold the lock in write mode. More... | |
| bool | attempt_upgrade () |
| Try to upgrade from READ to WRITE mode. Fail if any other threads are waiting. More... | |
| void | downgrade () |
| Atomically downgrade the lock from WRITE to READ mode. More... | |
Private Types | |
| typedef queue_based_lock_t | parent_lock |
Private Member Functions | |
| int | _spin_on_writer () |
| void | _spin_on_readers () |
| bool | _attempt_write (unsigned int expected) |
| void | _add_when_writer_leaves (int delta) |
Private Attributes | |
| unsigned int volatile | _holders |
Additional Inherited Members | |
Protected Member Functions inherited from mcs_lock | |
| mcs_lock () | |
| void | spin_on_waiting (qnode *me) |
| bool | attempt (ext_qnode *me) |
| bool | attempt (qnode *me) |
| void * | acquire (ext_qnode *me) |
| void * | acquire (qnode *me) |
| qnode * | __unsafe_begin_acquire (qnode *me) |
| void * | __unsafe_end_acquire (qnode *me, qnode *pred) |
| qnode * | spin_on_next (qnode *me) |
| void | release (ext_qnode *me) |
| void | release (ext_qnode &me) |
| void | release (qnode &me) |
| void | release (qnode *me) |
| bool | is_mine (ext_qnode *me) |
Protected Attributes inherited from mcs_lock | |
| qnode * | _tail |
Shore read-write lock:: many-reader/one-writer spin lock.
This read-write lock is implemented around a queue-based lock. It is the basis for latches in the storage manager.
Use this to protect data structures that get constantly hammered by short reads, and less frequently (but still often) by short writes.
"Short" is the key word here, since this is spin-based.
|
private |
| enum mcs_rwlock::rwmode_t |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
| void mcs_rwlock::acquire_read | ( | ) |
Wait (spin) until acquired.
| void mcs_rwlock::acquire_write | ( | ) |
Wait (spin) until acquired.
| bool mcs_rwlock::attempt_read | ( | ) |
True if success.
| bool mcs_rwlock::attempt_upgrade | ( | ) |
Try to upgrade from READ to WRITE mode. Fail if any other threads are waiting.
| bool mcs_rwlock::attempt_write | ( | ) |
True if success.
| void mcs_rwlock::downgrade | ( | ) |
Atomically downgrade the lock from WRITE to READ mode.
|
inline |
True iff has one or more readers.
|
inline |
True iff has a writer (never more than 1)
|
inline |
True if locked in any mode.
|
inline |
Return the mode in which this lock is held by anyone.
|
inline |
1 if held in write mode, else it's the number of readers
| void mcs_rwlock::release_read | ( | ) |
This thread had better hold the lock in read mode.
| void mcs_rwlock::release_write | ( | ) |
This thread had better hold the lock in write mode.
|
private |
1.8.12