MySQL 9.1.0
Source Code Documentation
|
Portable implementation of special type of read-write locks. More...
#include <thr_rwlock_bits.h>
Public Attributes | |
native_mutex_t | lock |
Lock which protects the structure. More... | |
native_cond_t | no_active_readers |
Condition variable which is used to wake-up writers waiting for readers to go away. More... | |
unsigned int | active_readers |
Number of active readers. More... | |
unsigned int | writers_waiting_readers |
Number of writers waiting for readers to go away. More... | |
bool | active_writer |
Indicates whether there is an active writer. More... | |
my_thread_t | writer_thread |
Thread holding wr-lock (for debug purposes only). More... | |
Portable implementation of special type of read-write locks.
These locks have two properties which are unusual for rwlocks: 1) They "prefer readers" in the sense that they do not allow situations in which rwlock is rd-locked and there is a pending rd-lock which is blocked (e.g. due to pending request for wr-lock). This is a stronger guarantee than one which is provided for PTHREAD_RWLOCK_PREFER_READER_NP rwlocks in Linux. MDL subsystem deadlock detector relies on this property for its correctness. 2) They are optimized for uncontended wr-lock/unlock case. This is scenario in which they are most often used within MDL subsystem. Optimizing for it gives significant performance improvements in some of tests involving many connections.
Another important requirement imposed on this type of rwlock by the MDL subsystem is that it should be OK to destroy rwlock object which is in unlocked state even though some threads might have not yet fully left unlock operation for it (of course there is an external guarantee that no thread will try to lock rwlock which is destroyed). Putting it another way the unlock operation should not access rwlock data after changing its state to unlocked.
TODO/FIXME: We should consider alleviating this requirement as it blocks us from doing certain performance optimizations.
unsigned int rw_pr_lock_t::active_readers |
Number of active readers.
bool rw_pr_lock_t::active_writer |
Indicates whether there is an active writer.
native_mutex_t rw_pr_lock_t::lock |
Lock which protects the structure.
Also held for the duration of wr-lock.
native_cond_t rw_pr_lock_t::no_active_readers |
Condition variable which is used to wake-up writers waiting for readers to go away.
my_thread_t rw_pr_lock_t::writer_thread |
Thread holding wr-lock (for debug purposes only).
unsigned int rw_pr_lock_t::writers_waiting_readers |
Number of writers waiting for readers to go away.