bare_sync/
lib.rs

1#![no_std]
2pub mod signal;
3pub mod watch;
4
5use core::marker::PhantomData;
6pub use embassy_sync::blocking_mutex::raw::RawMutex;
7pub use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
8
9/// A mutex that allows borrowing data in a global context.
10///
11/// **Warning: Do not use with multiple executors or interrupts**
12///
13/// When working with multiple executors or interrupts, you must use
14/// `embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex` instead.
15///
16/// # Safety
17///
18/// **This Mutex is only safe within a single executor and no interrupts.**
19#[derive(Debug)]
20pub struct NoopSyncRawMutex {
21    _phantom: PhantomData<*mut ()>,
22}
23
24unsafe impl Send for NoopSyncRawMutex {}
25unsafe impl Sync for NoopSyncRawMutex {}
26
27impl NoopSyncRawMutex {
28    /// Create a new `NoopSyncRawMutex`.
29    pub const fn new() -> Self {
30        Self {
31            _phantom: PhantomData,
32        }
33    }
34}
35
36unsafe impl RawMutex for NoopSyncRawMutex {
37    const INIT: Self = Self::new();
38    fn lock<R>(&self, f: impl FnOnce() -> R) -> R {
39        f()
40    }
41}