aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src/blocking_rwlock
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-sync/src/blocking_rwlock')
-rw-r--r--embassy-sync/src/blocking_rwlock/mod.rs6
-rw-r--r--embassy-sync/src/blocking_rwlock/raw.rs12
2 files changed, 12 insertions, 6 deletions
diff --git a/embassy-sync/src/blocking_rwlock/mod.rs b/embassy-sync/src/blocking_rwlock/mod.rs
index a304b77d6..a8fb7d6bc 100644
--- a/embassy-sync/src/blocking_rwlock/mod.rs
+++ b/embassy-sync/src/blocking_rwlock/mod.rs
@@ -1,11 +1,11 @@
1//! Blocking read-write lock. 1//! Blocking read-write lock.
2//! 2//!
3//! This module provides a blocking read-write lock that can be used to synchronize data. 3//! This module provides a blocking read-write lock that can be used to synchronize data.
4pub mod raw_rwlock; 4pub mod raw;
5 5
6use core::cell::UnsafeCell; 6use core::cell::UnsafeCell;
7 7
8use self::raw_rwlock::RawRwLock; 8use self::raw::RawRwLock;
9 9
10/// Blocking read-write lock (not async) 10/// Blocking read-write lock (not async)
11/// 11///
@@ -218,4 +218,4 @@ mod thread_mode_rwlock {
218 // Drop of the inner `T` happens after this. 218 // Drop of the inner `T` happens after this.
219 } 219 }
220 } 220 }
221} \ No newline at end of file 221}
diff --git a/embassy-sync/src/blocking_rwlock/raw.rs b/embassy-sync/src/blocking_rwlock/raw.rs
index 85e8374b5..7725edfa5 100644
--- a/embassy-sync/src/blocking_rwlock/raw.rs
+++ b/embassy-sync/src/blocking_rwlock/raw.rs
@@ -126,13 +126,19 @@ mod thread_mode {
126 unsafe impl RawRwLock for ThreadModeRawRwLock { 126 unsafe impl RawRwLock for ThreadModeRawRwLock {
127 const INIT: Self = Self::new(); 127 const INIT: Self = Self::new();
128 fn read_lock<R>(&self, f: impl FnOnce() -> R) -> R { 128 fn read_lock<R>(&self, f: impl FnOnce() -> R) -> R {
129 assert!(in_thread_mode(), "ThreadModeRwLock can only be locked from thread mode."); 129 assert!(
130 in_thread_mode(),
131 "ThreadModeRwLock can only be locked from thread mode."
132 );
130 133
131 f() 134 f()
132 } 135 }
133 136
134 fn write_lock<R>(&self, f: impl FnOnce() -> R) -> R { 137 fn write_lock<R>(&self, f: impl FnOnce() -> R) -> R {
135 assert!(in_thread_mode(), "ThreadModeRwLock can only be locked from thread mode."); 138 assert!(
139 in_thread_mode(),
140 "ThreadModeRwLock can only be locked from thread mode."
141 );
136 142
137 f() 143 f()
138 } 144 }
@@ -156,4 +162,4 @@ mod thread_mode {
156 } 162 }
157} 163}
158#[cfg(any(cortex_m, feature = "std"))] 164#[cfg(any(cortex_m, feature = "std"))]
159pub use thread_mode::*; \ No newline at end of file 165pub use thread_mode::*;