Skip to main content

SlabStore

Trait SlabStore 

Source
pub unsafe trait SlabStore {
    type Item;

    // Required methods
    fn alloc(&self, value: Self::Item) -> Slot<Self::Item>;
    fn free(&self, slot: Slot<Self::Item>);
    fn take(&self, slot: Slot<Self::Item>) -> Self::Item;
}
Expand description

Base trait for slab storage — allocation, deallocation, and value extraction.

§Allocation

alloc always returns a valid slot:

  • Unbounded slabs grow as needed — allocation never fails.
  • Bounded slabs panic if capacity is exceeded. This is intentional: running out of pre-allocated capacity is a capacity planning error, equivalent to OOM. The system should crash loudly rather than silently drop work.

For fallible allocation on bounded slabs, use BoundedStore::try_alloc.

§Safety

Implementors must uphold:

  • free must drop the value and return the slot to the freelist.
  • take must move the value out and return the slot to the freelist.
  • The slot must have been allocated from self.

Required Associated Types§

Source

type Item

The type stored in each slot.

Required Methods§

Source

fn alloc(&self, value: Self::Item) -> Slot<Self::Item>

Allocates a slot with the given value.

§Panics

Panics if the store is at capacity (bounded slabs only). This is a capacity planning error — size your slabs for peak load.

Source

fn free(&self, slot: Slot<Self::Item>)

Drops the value and returns the slot to the freelist.

Source

fn take(&self, slot: Slot<Self::Item>) -> Self::Item

Moves the value out and returns the slot to the freelist.

Implementors§

Source§

impl<T> SlabStore for nexus_timer::store::BoundedSlab<T>

Source§

type Item = T

Source§

impl<T> SlabStore for nexus_timer::store::UnboundedSlab<T>

Source§

type Item = T