Type Alias mariadb_sys::rw_pr_lock_t
source · pub type rw_pr_lock_t = st_rw_pr_lock_t;
Expand description
Portable implementation of special type of read-write locks.
These locks have two properties which are unusual for rwlocks:
- 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.
- They are optimized for uncontended wr-lock/unlock case. This is a scenario in which they are most often used within MDL subsystem. Optimizing for it gives significant performance improvements in some of the 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.
Aliased Type§
struct rw_pr_lock_t {
pub lock: pthread_mutex_t,
pub no_active_readers: pthread_cond_t,
pub active_readers: u32,
pub writers_waiting_readers: u32,
pub active_writer: i8,
}
Fields§
§lock: pthread_mutex_t
Lock which protects the structure. Also held for the duration of wr-lock.
no_active_readers: pthread_cond_t
Condition variable which is used to wake-up writers waiting for readers to go away.
active_readers: u32
Number of active readers.
writers_waiting_readers: u32
Number of writers waiting for readers to go away.
active_writer: i8
Indicates whether there is an active writer.