MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
st_rw_pr_lock_t Struct Reference

#include <my_pthread.h>

Public Attributes

pthread_mutex_t lock
pthread_cond_t no_active_readers
uint active_readers
uint writers_waiting_readers
my_bool active_writer

Detailed Description

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 oftenly 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.

Definition at line 640 of file my_pthread.h.

Member Data Documentation

uint st_rw_pr_lock_t::active_readers

Number of active readers.

Definition at line 652 of file my_pthread.h.

my_bool st_rw_pr_lock_t::active_writer

Indicates whether there is an active writer.

Definition at line 656 of file my_pthread.h.

pthread_mutex_t st_rw_pr_lock_t::lock

Lock which protects the structure. Also held for the duration of wr-lock.

Definition at line 645 of file my_pthread.h.

pthread_cond_t st_rw_pr_lock_t::no_active_readers

Condition variable which is used to wake-up writers waiting for readers to go away.

Definition at line 650 of file my_pthread.h.

uint st_rw_pr_lock_t::writers_waiting_readers

Number of writers waiting for readers to go away.

Definition at line 654 of file my_pthread.h.


The documentation for this struct was generated from the following file: