#[repr(C)]
pub struct st_rw_pr_lock_t { pub lock: pthread_mutex_t, pub no_active_readers: pthread_cond_t, pub active_readers: uint, pub writers_waiting_readers: uint, pub active_writer: my_bool, }
Expand 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 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.

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: uint

Number of active readers.

§writers_waiting_readers: uint

Number of writers waiting for readers to go away.

§active_writer: my_bool

Indicates whether there is an active writer.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.