pub struct RawOsMutex<T: UnsafeRawOsMutex> { /* private fields */ }Expand description
Platform mutex primitives for use with [Mutex] and [MutexWrap].
While the std::sync::Mutex type only uses one kind of platform mutex
primitive (except on Windows, where things are a little convoluted),
flexible-locks allow to use different kinds.
The available primitives are:
pthread_mutex_t, on Unix-like systems, including macOS,OSSpinLockon macOS,SRWLockon Windows,CRITICAL_SECTIONon Windows.
Other primitives could be added in the future, such as os_unfair_lock_t
on macOS.
For types that can be statically initialized, until const fn is
stabilized, initializer macros are provided:
For non-static initialization, Default::default() can be used for these.
For more specific non default use cases, you may want to implement your own
type and implement the RawMutex or UnsafeRawOsMutex trait for it.
§Safety
Generally speaking, platform mutex primitives cannot be moved in memory. That is, they must stay at the same address. Please ensure that is the case when you use them.