Skip to content

Commit 3e0114e

Browse files
Move Sync impl to the rest of the mutex code
1 parent 1f25953 commit 3e0114e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ impl<T> Mutex<T> {
5353
}
5454
}
5555

56+
// NOTE A `Mutex` can be used as a channel so the protected data must be `Send`
57+
// to prevent sending non-Sendable stuff (e.g. access tokens) across different
58+
// execution contexts (e.g. interrupts)
59+
unsafe impl<T> Sync for Mutex<T> where T: Send {}
60+
5661
/// ``` compile_fail
5762
/// fn bad(cs: bare_metal::CriticalSection) -> &u32 {
5863
/// let x = bare_metal::Mutex::new(42u32);
@@ -67,8 +72,3 @@ pub unsafe trait Nr {
6772
/// Returns the number associated with an interrupt
6873
fn nr(&self) -> u8;
6974
}
70-
71-
// NOTE A `Mutex` can be used as a channel so the protected data must be `Send`
72-
// to prevent sending non-Sendable stuff (e.g. access tokens) across different
73-
// execution contexts (e.g. interrupts)
74-
unsafe impl<T> Sync for Mutex<T> where T: Send {}

0 commit comments

Comments
 (0)