Skip to content

Commit 4d4ee9b

Browse files
committed
zephyr: sys: sync: Mutex: Implement Send/Sync
Although it is tradition in Rust to have types such as Semaphores and Mutexes not implement Sync, these primitives, built as thing wrappers become fairly useless. Sharing them would require `Arc`, which requires alloc. Presumably someone wanting to use lower level primitives would also not likely be wanting to use allocation. For the most part, these primtives have as their real purpose to be used in the implementation of the higher level synchronization primtives, such as sync::Mutex. unlock is unsafe because it is required to only call unlock on the same thread that locked. Signed-off-by: David Brown <[email protected]>
1 parent c0434a2 commit 4d4ee9b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

zephyr/src/sys/sync/mutex.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ impl Mutex {
9090
/// [`init_once`]: StaticMutex::init_once
9191
pub type StaticMutex = StaticKernelObject<k_mutex>;
9292

93+
unsafe impl Sync for Mutex {}
94+
unsafe impl Send for Mutex {}
95+
9396
// Sync and Send are meaningful, as the underlying Zephyr API can use these values from any thread.
9497
// Care must be taken to use these in a safe manner.
9598
unsafe impl Sync for StaticMutex {}

0 commit comments

Comments
 (0)