lock_order::lock

Trait UnlockedAccess

Source
pub trait UnlockedAccess<A> {
    type Data;
    type Guard<'l>: Deref<Target = Self::Data>
       where Self: 'l;

    // Required method
    fn access(&self) -> Self::Guard<'_>;
}
Expand description

Describes how to access state in Self that doesn’t require locking.

UnlockedAccess allows access to some state in Self without acquiring a lock. Unlike Lock and friends, the type parameter A in UnlockedAccess<A> is used to provide a label for the state; it is unrelated to the lock levels for Self.

In order for this crate to provide guarantees about lock ordering safety, UnlockedAccess must only be implemented for accessing state that is guaranteed to be accessible lock-free.

Required Associated Types§

Source

type Data

The type of state being accessed.

Source

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

A guard providing read access to the data.

Required Methods§

Source

fn access(&self) -> Self::Guard<'_>

How to access the state.

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> UnlockedAccess<L> for T

Source§

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

Source§

type Guard<'l> = &'l <L as UnlockedAccessMarkerFor<T>>::Data where Self: 'l