RawMutex

Trait RawMutex 

Source
pub trait RawMutex: Send + Sync {
    // Required methods
    unsafe fn lock(&self);
    unsafe fn unlock(&self);

    // Provided methods
    unsafe fn init(&mut self) { ... }
    unsafe fn destroy(&self) { ... }
}
Expand description

A trait for raw mutual exclusion primitives.

Required Methods§

Source

unsafe fn lock(&self)

Acquire the raw mutex.

Source

unsafe fn unlock(&self)

Release the raw mutex.

Provided Methods§

Source

unsafe fn init(&mut self)

Initialize the raw mutex.

Because initializing an instance may involve moving its location when doing e.g. Box::new(Foo::new()), because some types of raw mutex primitives need to be initialized at their final, permanent location (e.g. CRITICAL_SECTION), or because some may not be statically initialized to an entirely satisfying state (e.g. pthread_mutex_t, see issue #33770), this method is called from Mutex::new to finish the raw mutex initialization.

Source

unsafe fn destroy(&self)

Destroy the raw mutex.

In some cases, raw mutex primitives need to be cleaned up after use, so this method is called when a Mutex is dropped.

Implementations on Foreign Types§

Source§

impl<T: RawMutex> RawMutex for Box<T>

Available on crate features std only.

Wrapping a RawMutex in a Box is just as good a valid RawMutex.

Ideally, any type that derefs to a RawMutex would be good too, but without specialization, this would prevent implementing RawMutex on your own mutex types.

Source§

unsafe fn init(&mut self)

Source§

unsafe fn lock(&self)

Source§

unsafe fn unlock(&self)

Source§

unsafe fn destroy(&self)

Implementors§