1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Locking traits and implementations.
//!
//! This allows for mutexes in a `no_std` environment, where there is no generic
//! mutex type. Users are encouraged to implement this trait for a custom type,
//! however some implementations are provided.
//!
//! # Default implementations
//! With the `std` feature, this crate provides an implementation for
//! [`std::sync::Mutex`], and with the `spin` feature, this crate provides an
//! implementation for [`spin::Mutex`]. The std implementation is recommended
//! for situations where libstd is available. The spin implementation is [not
//! recommended](https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html),
//! however. If possible, implement your own non-spinning lock type.
use Mutex;
/// A trait for types that can be used as locks.
///
/// In order to avoid exposing private types, this lock is typeless and does not
/// actually store the value directly. It should usually be implemented with a
/// mutex with an empty data field.
///
/// # Safety
/// The type must provide unique access to the underlying data, like a mutex
/// would.
pub unsafe
unsafe
unsafe