pub trait IdAllocator: BaseAllocator {
    // Required methods
    fn alloc_id(
        &mut self,
        count: usize,
        align_pow2: usize
    ) -> AllocResult<usize>;
    fn dealloc_id(&mut self, start_id: usize, count: usize);
    fn is_allocated(&self, id: usize) -> bool;
    fn alloc_fixed_id(&mut self, id: usize) -> AllocResult;
    fn size(&self) -> usize;
    fn used(&self) -> usize;
    fn available(&self) -> usize;
}
Expand description

Used to allocate unique IDs (e.g., thread ID).

Required Methods§

source

fn alloc_id(&mut self, count: usize, align_pow2: usize) -> AllocResult<usize>

Allocate contiguous IDs with given count and alignment.

source

fn dealloc_id(&mut self, start_id: usize, count: usize)

Deallocate contiguous IDs with given position and count.

source

fn is_allocated(&self, id: usize) -> bool

Whether the given id was allocated.

source

fn alloc_fixed_id(&mut self, id: usize) -> AllocResult

Mark the given id has been allocated and cannot be reallocated.

source

fn size(&self) -> usize

Returns the maximum number of supported IDs.

source

fn used(&self) -> usize

Returns the number of allocated IDs.

source

fn available(&self) -> usize

Returns the number of available IDs.

Implementors§