bare-sync 0.1.0

no-std, no-alloc synchronization primitives
Documentation
#![no_std]
pub mod signal;
pub mod watch;

use core::marker::PhantomData;
use embassy_sync::blocking_mutex::raw::RawMutex;

/// A mutex that allows borrowing data in a global context.
///
/// **Warning: Do not use with multiple executors or interrupts**
///
/// When working with multiple executors or interrupts, you must use
/// `embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex` instead.
///
/// # Safety
///
/// **This Mutex is only safe within a single executor and no interrupts.**
#[derive(Debug)]
pub struct NoopSyncRawMutex {
    _phantom: PhantomData<*mut ()>,
}

unsafe impl Send for NoopSyncRawMutex {}
unsafe impl Sync for NoopSyncRawMutex {}

impl NoopSyncRawMutex {
    /// Create a new `NoopSyncRawMutex`.
    pub const fn new() -> Self {
        Self {
            _phantom: PhantomData,
        }
    }
}

unsafe impl RawMutex for NoopSyncRawMutex {
    const INIT: Self = Self::new();
    fn lock<R>(&self, f: impl FnOnce() -> R) -> R {
        f()
    }
}