Struct vm_allocator::IdAllocator
source · [−]pub struct IdAllocator { /* private fields */ }
Expand description
An unique ID allocator that allows management of IDs in a given interval.
Implementations
sourceimpl IdAllocator
impl IdAllocator
sourcepub fn new(range_base: u32, range_end: u32) -> Result<Self>
pub fn new(range_base: u32, range_end: u32) -> Result<Self>
Creates a new instance of IdAllocator that will be used to manage the
allocation and release of ids from the interval specified by
range_base
and range_end
sourcepub fn allocate_id(&mut self) -> Result<u32>
pub fn allocate_id(&mut self) -> Result<u32>
Allocate an ID from the managed range. We first try to reuse one of the IDs released before. If there is no ID to reuse we return the next available one from the managed range.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for IdAllocator
impl Send for IdAllocator
impl Sync for IdAllocator
impl Unpin for IdAllocator
impl UnwindSafe for IdAllocator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more