attachable-slab-allocator 0.1.0

A high-performance, $O(1)$, Master-Slave slab allocator designed for `no_std` environments, kernels, and embedded systems. This library provides fixed-size memory management with RAII safety while remaining completely agnostic of the underlying memory provider.
Documentation
//! # No-Operation Lock
//!
//! `NoLock` is a "dummy" synchronization primitive that performs no actual locking.
//! Use this when your application is guaranteed to be single-threaded or when
//! higher-level logic ensures mutual exclusion.
//!
//! ## Performance
//! This is a zero-cost abstraction. The `lock()` call is a no-op and the compiler
//! will likely optimize it away entirely.

use super::lock_trait::LockTrait;
use core::marker::PhantomData;

/// A non-functional lock for single-threaded use.
///
/// It contains padding to ensure that even a "no-lock" slab header maintains
/// a predictable memory footprint.
pub struct NoLock {
    _dummy: u64,
    _dummy2: u64,
    /// PhantomData prevents the type from being `Send`/`Sync` by default,
    /// reinforcing that it's for single-threaded contexts.
    _marker: PhantomData<*const ()>,
}

impl LockTrait for NoLock {
    /// The guard for NoLock is an empty unit type `()`.
    type Guard<'a> = ();

    /// Returns immediately without doing anything.
    fn lock(&self) -> Self::Guard<'_> {}

    /// Creates a new `NoLock` instance.
    fn init() -> Self {
        Self {
            _dummy: 0,
            _dummy2: 0,
            _marker: PhantomData,
        }
    }
}