Trait allocator::IdAllocator
source · 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§
sourcefn alloc_id(&mut self, count: usize, align_pow2: usize) -> AllocResult<usize>
fn alloc_id(&mut self, count: usize, align_pow2: usize) -> AllocResult<usize>
Allocate contiguous IDs with given count and alignment.
sourcefn dealloc_id(&mut self, start_id: usize, count: usize)
fn dealloc_id(&mut self, start_id: usize, count: usize)
Deallocate contiguous IDs with given position and count.
sourcefn is_allocated(&self, id: usize) -> bool
fn is_allocated(&self, id: usize) -> bool
Whether the given id
was allocated.
sourcefn alloc_fixed_id(&mut self, id: usize) -> AllocResult
fn alloc_fixed_id(&mut self, id: usize) -> AllocResult
Mark the given id
has been allocated and cannot be reallocated.