low-latency-data-structures 0.0.7

Experimental lock-free SPSC, SPMC broadcast, and SeqLock primitives tuned for ultra-low-latency systems
Documentation
use bon::Builder;

use crate::mem::Allocator;
use crate::mem::global::{GlobalAllocator, GlobalAllocatorOptions};

/// Construction-time options for [`new`](super::new).
///
/// Wraps the allocator-specific options so the same `new` signature works for
/// every [`Allocator`] impl. Use [`Options::builder`] to build one explicitly,
/// or [`Options::global_mlocked`] for the common global + `mlock` case.
#[derive(Builder)]
pub struct Options<A>
where
    A: Allocator,
{
    pub(crate) alloc: A::Options,
}

impl Options<GlobalAllocator> {
    /// Convenience shorthand for the common case: the global allocator with
    /// `mlock` enabled.
    pub fn global_mlocked() -> Self {
        Self {
            alloc: GlobalAllocatorOptions::builder().mlock(true).build(),
        }
    }
}