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§
Provided Methods§
Sourceunsafe fn init(&mut self)
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.
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.
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.