diff options
| author | Ulf Lilleengen <[email protected]> | 2022-06-15 13:06:35 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-06-15 13:06:35 +0200 |
| commit | 25ddb26be815ec3029ea9d28ba812bd541a0face (patch) | |
| tree | a3551396554b04a3c5bf3d552bf719d66a9555dd | |
| parent | eb237337671af5c9be7fc120e5d5235039dc5e5a (diff) | |
Improve mutex wording
| -rw-r--r-- | embassy/src/blocking_mutex/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/embassy/src/blocking_mutex/mod.rs b/embassy/src/blocking_mutex/mod.rs index 65daf15c4..602ec8a07 100644 --- a/embassy/src/blocking_mutex/mod.rs +++ b/embassy/src/blocking_mutex/mod.rs | |||
| @@ -11,13 +11,17 @@ use self::raw::RawMutex; | |||
| 11 | /// | 11 | /// |
| 12 | /// Provides a blocking mutual exclusion primitive backed by an implementation of [`raw::RawMutex`]. | 12 | /// Provides a blocking mutual exclusion primitive backed by an implementation of [`raw::RawMutex`]. |
| 13 | /// | 13 | /// |
| 14 | /// Which implementation you select depends on the context in which you're using the mutex. | 14 | /// Which implementation you select depends on the context in which you're using the mutex, and you can choose which kind |
| 15 | /// of interior mutability fits your use case. | ||
| 15 | /// | 16 | /// |
| 16 | /// Use [`CriticalSectionMutex`] when data can be shared between threads and interrupts. | 17 | /// Use [`CriticalSectionMutex`] when data can be shared between threads and interrupts. |
| 17 | /// | 18 | /// |
| 18 | /// Use [`NoopMutex`] when data is only shared between tasks running on the same executor. | 19 | /// Use [`NoopMutex`] when data is only shared between tasks running on the same executor. |
| 19 | /// | 20 | /// |
| 20 | /// Use [`ThreadModeMutex`] when data is shared between tasks running on the same executor but you want a global singleton. | 21 | /// Use [`ThreadModeMutex`] when data is shared between tasks running on the same executor but you want a global singleton. |
| 22 | /// | ||
| 23 | /// In all cases, the blocking mutex is intended to be short lived and not held across await points. | ||
| 24 | /// Use the async [`Mutex`](crate::mutex::Mutex) if you need a lock that is held across await points. | ||
| 21 | pub struct Mutex<R, T: ?Sized> { | 25 | pub struct Mutex<R, T: ?Sized> { |
| 22 | // NOTE: `raw` must be FIRST, so when using ThreadModeMutex the "can't drop in non-thread-mode" gets | 26 | // NOTE: `raw` must be FIRST, so when using ThreadModeMutex the "can't drop in non-thread-mode" gets |
| 23 | // to run BEFORE dropping `data`. | 27 | // to run BEFORE dropping `data`. |
