Skip to main content

LocalMutexLike

Trait LocalMutexLike 

Source
pub trait LocalMutexLike<T: 'static> {
    type Guard<'guard>: DerefMut<Target = T>
       where Self: 'guard;

    // Required method
    fn lock(&self) -> impl Future<Output = Self::Guard<'_>>;
}
Expand description

Non-Send mutex shape for runtimes that pin tasks to a single core. The guard is !Send so callers can’t accidentally move it across cores; in exchange the underlying primitive can skip the atomic/notification dance a Send Mutex needs.

Implementations are typically Rc<RefCell<T>>-shaped plus a per-core VecDeque<Waker> waiter queue. Not exposed on RuntimeFactory because tokio’s multi-thread runtime can’t honor the !Send guard contract — LocalRuntimeFactory is a separate opt-in for prime-style per-core-pinned runtimes.

Required Associated Types§

Source

type Guard<'guard>: DerefMut<Target = T> where Self: 'guard

Required Methods§

Source

fn lock(&self) -> impl Future<Output = Self::Guard<'_>>

Acquire the lock. The returned future is !Send so it can only be polled by the core that spawned it.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§