lock_order::lock

Trait RwLockFor

Source
pub trait RwLockFor<L> {
    type Data;
    type ReadGuard<'l>: Deref<Target = Self::Data>
       where Self: 'l;
    type WriteGuard<'l>: DerefMut<Target = Self::Data>
       where Self: 'l;

    // Required methods
    fn read_lock(&self) -> Self::ReadGuard<'_>;
    fn write_lock(&self) -> Self::WriteGuard<'_>;
}
Expand description

Describes how to acquire reader and writer locks to the implementing type.

An implementation of RwLockFor<L> for some Self means that L is a valid lock level for T, and defines how to access the state in Self that is under the lock indicated by L in either read mode or write mode.

Required Associated Types§

Source

type Data

The data produced by locking the state indicated by L in Self.

Source

type ReadGuard<'l>: Deref<Target = Self::Data> where Self: 'l

A guard providing read access to the data.

Source

type WriteGuard<'l>: DerefMut<Target = Self::Data> where Self: 'l

A guard providing write access to the data.

Required Methods§

Source

fn read_lock(&self) -> Self::ReadGuard<'_>

Acquires a read lock on the data in Self indicated by L.

Source

fn write_lock(&self) -> Self::WriteGuard<'_>

Acquires a write lock on the data in Self indicated by L.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<L, T> RwLockFor<L> for T

Source§

type Data = <L as LockLevelFor<T>>::Data

Source§

type ReadGuard<'l> = <<T as OrderedLockAccess<<L as LockLevelFor<T>>::Data>>::Lock as ReadWriteLock<<L as LockLevelFor<T>>::Data>>::ReadGuard<'l> where Self: 'l

Source§

type WriteGuard<'l> = <<T as OrderedLockAccess<<L as LockLevelFor<T>>::Data>>::Lock as ReadWriteLock<<L as LockLevelFor<T>>::Data>>::WriteGuard<'l> where Self: 'l