Skip to main content

Module talc

Module talc 

Source
Expand description

Talc allocator integration.

TalcAlloc is a type alias for &'static CacheTalcLock. Talc’s Talck already implements allocator_api2::alloc::Allocator, and &'static T inherits that impl. The whole “allocator handle” is just a borrow — Copy + Clone + Send + Sync for free.

Construction is one line at the call site:

  • Tests: &TALC where static TALC: CacheTalcLock = new_cache_talc_lock(); (see the test_arena helper).
  • Production: the talc lives at a fixed VA (mmap’d, pinned for the process lifetime):
    let alloc: TalcAlloc =
        unsafe { &*(STATE_CACHE_VA as *const CacheTalcLock) };
    The single unsafe { &*VA } cast asserts the 'static lifetime that the mmap pinning guarantees.

Structs§

ClaimOnOom
An out-of-memory handler that attempts to claim the memory within the given Span upon OOM.
ErrOnOom
Doesn’t handle out-of-memory conditions, immediate allocation error occurs.
Mutex
A mutual exclusion primitive useful for protecting shared data
MutexGuard
An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
RawSpinlock
Provides mutual exclusion based on spinning on an AtomicBool.
Span
Represents an interval of memory [base, acme)
Talc
The Talc Allocator!
Talck
Talc lock, contains a mutex-locked Talc.

Traits§

OomHandler

Functions§

new_cache_talc_lock
Const constructor for a fresh empty CacheTalcLock. Suitable for a static binding; backing memory must be supplied at runtime via lock.lock().claim(Span::from_array(...)).

Type Aliases§

CacheTalcLock
Concrete Talck flavour used by the shared state-cache region.
TalcAlloc
Workspace allocator handle. Just a 'static borrow of a CacheTalcLockCopy + Clone + Send + Sync by reference, and the underlying Talck already impls allocator_api2::alloc::Allocator.