diff options
| author | Alix ANNERAUD <[email protected]> | 2025-02-28 16:41:41 +0100 |
|---|---|---|
| committer | Alix ANNERAUD <[email protected]> | 2025-02-28 16:41:41 +0100 |
| commit | 55684782258b0241ede93ac6e43a07a3075ad028 (patch) | |
| tree | c619083a7c55a78f175bae4045ae53329e486d2d /embassy-sync/src/blocking_rwlock/mod.rs | |
| parent | 33cf27adf646bacd758b7289ebbf460b24c26fa5 (diff) | |
Fix module references in blocking read-write lock implementation
Diffstat (limited to 'embassy-sync/src/blocking_rwlock/mod.rs')
| -rw-r--r-- | embassy-sync/src/blocking_rwlock/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/embassy-sync/src/blocking_rwlock/mod.rs b/embassy-sync/src/blocking_rwlock/mod.rs index a8fb7d6bc..88cd2164b 100644 --- a/embassy-sync/src/blocking_rwlock/mod.rs +++ b/embassy-sync/src/blocking_rwlock/mod.rs | |||
| @@ -9,7 +9,7 @@ use self::raw::RawRwLock; | |||
| 9 | 9 | ||
| 10 | /// Blocking read-write lock (not async) | 10 | /// Blocking read-write lock (not async) |
| 11 | /// | 11 | /// |
| 12 | /// Provides a blocking read-write lock primitive backed by an implementation of [`raw_rwlock::RawRwLock`]. | 12 | /// Provides a blocking read-write lock primitive backed by an implementation of [`raw::RawRwLock`]. |
| 13 | /// | 13 | /// |
| 14 | /// Which implementation you select depends on the context in which you're using the read-write lock, and you can choose which kind | 14 | /// Which implementation you select depends on the context in which you're using the read-write lock, and you can choose which kind |
| 15 | /// of interior mutability fits your use case. | 15 | /// of interior mutability fits your use case. |
| @@ -94,16 +94,16 @@ impl<R, T> RwLock<R, T> { | |||
| 94 | /// # Safety | 94 | /// # Safety |
| 95 | /// | 95 | /// |
| 96 | /// This read-write lock is safe to share between different executors and interrupts. | 96 | /// This read-write lock is safe to share between different executors and interrupts. |
| 97 | pub type CriticalSectionRwLock<T> = RwLock<raw_rwlock::CriticalSectionRawRwLock, T>; | 97 | pub type CriticalSectionRwLock<T> = RwLock<raw::CriticalSectionRawRwLock, T>; |
| 98 | 98 | ||
| 99 | /// A read-write lock that allows borrowing data in the context of a single executor. | 99 | /// A read-write lock that allows borrowing data in the context of a single executor. |
| 100 | /// | 100 | /// |
| 101 | /// # Safety | 101 | /// # Safety |
| 102 | /// | 102 | /// |
| 103 | /// **This Read-Write Lock is only safe within a single executor.** | 103 | /// **This Read-Write Lock is only safe within a single executor.** |
| 104 | pub type NoopRwLock<T> = RwLock<raw_rwlock::NoopRawRwLock, T>; | 104 | pub type NoopRwLock<T> = RwLock<raw::NoopRawRwLock, T>; |
| 105 | 105 | ||
| 106 | impl<T> RwLock<raw_rwlock::CriticalSectionRawRwLock, T> { | 106 | impl<T> RwLock<raw::CriticalSectionRawRwLock, T> { |
| 107 | /// Borrows the data for the duration of the critical section | 107 | /// Borrows the data for the duration of the critical section |
| 108 | pub fn borrow<'cs>(&'cs self, _cs: critical_section::CriticalSection<'cs>) -> &'cs T { | 108 | pub fn borrow<'cs>(&'cs self, _cs: critical_section::CriticalSection<'cs>) -> &'cs T { |
| 109 | let ptr = self.data.get() as *const T; | 109 | let ptr = self.data.get() as *const T; |
| @@ -111,7 +111,7 @@ impl<T> RwLock<raw_rwlock::CriticalSectionRawRwLock, T> { | |||
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | impl<T> RwLock<raw_rwlock::NoopRawRwLock, T> { | 114 | impl<T> RwLock<raw::NoopRawRwLock, T> { |
| 115 | /// Borrows the data | 115 | /// Borrows the data |
| 116 | #[allow(clippy::should_implement_trait)] | 116 | #[allow(clippy::should_implement_trait)] |
| 117 | pub fn borrow(&self) -> &T { | 117 | pub fn borrow(&self) -> &T { |
| @@ -184,7 +184,7 @@ mod thread_mode_rwlock { | |||
| 184 | /// This will panic if not currently running in thread mode. | 184 | /// This will panic if not currently running in thread mode. |
| 185 | pub fn borrow(&self) -> &T { | 185 | pub fn borrow(&self) -> &T { |
| 186 | assert!( | 186 | assert!( |
| 187 | raw_rwlock::in_thread_mode(), | 187 | raw::in_thread_mode(), |
| 188 | "ThreadModeRwLock can only be borrowed from thread mode." | 188 | "ThreadModeRwLock can only be borrowed from thread mode." |
| 189 | ); | 189 | ); |
| 190 | unsafe { &*self.inner.get() } | 190 | unsafe { &*self.inner.get() } |
| @@ -197,7 +197,7 @@ mod thread_mode_rwlock { | |||
| 197 | /// This will panic if not currently running in thread mode. | 197 | /// This will panic if not currently running in thread mode. |
| 198 | pub fn borrow_mut(&self) -> &mut T { | 198 | pub fn borrow_mut(&self) -> &mut T { |
| 199 | assert!( | 199 | assert!( |
| 200 | raw_rwlock::in_thread_mode(), | 200 | raw::in_thread_mode(), |
| 201 | "ThreadModeRwLock can only be borrowed from thread mode." | 201 | "ThreadModeRwLock can only be borrowed from thread mode." |
| 202 | ); | 202 | ); |
| 203 | unsafe { &mut *self.inner.get() } | 203 | unsafe { &mut *self.inner.get() } |
| @@ -211,7 +211,7 @@ mod thread_mode_rwlock { | |||
| 211 | // T isn't, so without this check a user could create a ThreadModeRwLock in thread mode, | 211 | // T isn't, so without this check a user could create a ThreadModeRwLock in thread mode, |
| 212 | // send it to interrupt context and drop it there, which would "send" a T even if T is not Send. | 212 | // send it to interrupt context and drop it there, which would "send" a T even if T is not Send. |
| 213 | assert!( | 213 | assert!( |
| 214 | raw_rwlock::in_thread_mode(), | 214 | raw::in_thread_mode(), |
| 215 | "ThreadModeRwLock can only be dropped from thread mode." | 215 | "ThreadModeRwLock can only be dropped from thread mode." |
| 216 | ); | 216 | ); |
| 217 | 217 | ||
