pub struct HandleAllocator { /* private fields */ }Expand description
Handle-based allocator with relocation support.
Implementations§
Source§impl HandleAllocator
impl HandleAllocator
Sourcepub fn alloc_with_options<T>(
&self,
relocatable: bool,
on_relocate: Option<Box<dyn Fn(*mut u8, *mut u8) + Send + Sync>>,
) -> Option<Handle<T>>
pub fn alloc_with_options<T>( &self, relocatable: bool, on_relocate: Option<Box<dyn Fn(*mut u8, *mut u8) + Send + Sync>>, ) -> Option<Handle<T>>
Allocate with options.
Sourcepub fn resolve<T>(&self, handle: Handle<T>) -> Option<*const T>
pub fn resolve<T>(&self, handle: Handle<T>) -> Option<*const T>
Resolve a handle to a pointer.
Returns None if the handle is invalid or has been freed.
Sourcepub fn resolve_mut<T>(&self, handle: Handle<T>) -> Option<*mut T>
pub fn resolve_mut<T>(&self, handle: Handle<T>) -> Option<*mut T>
Resolve a handle to a mutable pointer.
Sourcepub fn defragment(&self) -> usize
pub fn defragment(&self) -> usize
Perform defragmentation by relocating memory.
This is a simple compaction that moves relocatable allocations to reduce fragmentation. Returns the number of relocations performed.
Sourcepub fn total_allocated(&self) -> u64
pub fn total_allocated(&self) -> u64
Get total allocated bytes.
Sourcepub fn active_count(&self) -> u32
pub fn active_count(&self) -> u32
Get number of active handles.
Sourcepub fn relocation_count(&self) -> u64
pub fn relocation_count(&self) -> u64
Get total relocations performed.
Sourcepub fn stats(&self) -> HandleAllocatorStats
pub fn stats(&self) -> HandleAllocatorStats
Get statistics about the handle allocator.
Trait Implementations§
Source§impl Default for HandleAllocator
impl Default for HandleAllocator
impl Send for HandleAllocator
impl Sync for HandleAllocator
Auto Trait Implementations§
impl !Freeze for HandleAllocator
impl RefUnwindSafe for HandleAllocator
impl Unpin for HandleAllocator
impl UnwindSafe for HandleAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more