Lock

Trait Lock 

Source
pub unsafe trait Lock: for<'this> Lifetime<'this> {
    // Required methods
    fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard;
    fn lock_shared(&self) -> <Self as Lifetime<'_>>::SharedGuard;
}
Expand description

A lock.

§Safety

This lock must uphold XOR mutability: at any give time either one exclusive guard or multiple shared guards can be handed out.

Note that the shared implementation does not actually have to be shared; it is just an optimization for implementations that support it.

Required Methods§

Source

fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard

Acquire an exclusive lock.

When called recursively, this function must panic, abort or deadlock.

If the previous guard was dropped during a panic, this function may or may not panic.

Source

fn lock_shared(&self) -> <Self as Lifetime<'_>>::SharedGuard

Acquire a shared lock.

When called recursively, this function may succeed, panic, abort or deadlock.

If the previous guard was dropped during a panic, this function may or may not panic.

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.

Implementations on Foreign Types§

Source§

impl<L: Lock> Lock for &L

Source§

fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard

Source§

fn lock_shared(&self) -> <Self as Lifetime<'_>>::SharedGuard

Source§

impl<L: Lock> Lock for &mut L

Source§

fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard

Source§

fn lock_shared(&self) -> <Self as Lifetime<'_>>::SharedGuard

Source§

impl<T> Lock for RefCell<T>

Source§

fn lock_exclusive(&self) -> <Self as Lifetime<'_>>::ExclusiveGuard

Source§

fn lock_shared(&self) -> <Self as Lifetime<'_>>::SharedGuard

Implementors§

Source§

impl<T> Lock for Local<T>