bare_sync/
lib.rs

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