pub struct Allocator { /* private fields */ }Implementations§
Source§impl Allocator
impl Allocator
Sourcepub unsafe fn create(
file: &File,
file_size: usize,
min_workers: u32,
slab_size: u32,
) -> Result<Self, Error>
pub unsafe fn create( file: &File, file_size: usize, min_workers: u32, slab_size: u32, ) -> Result<Self, Error>
Create a new Allocator in the provided file with the given parameters.
min_workers is the minimum number of workers to support.
§Safety
createmust only be called once for a given file. Subsequent calls with the same file must usejoin.
Sourcepub fn join(file: &File) -> Result<Self, Error>
pub fn join(file: &File) -> Result<Self, Error>
Join an existing allocator in the provided file. Picks the first available worker slot.
§Note
Prefer Self::join_from_existing to re-use mmaps within the same
process.
Sourcepub fn join_from_existing(existing: &Allocator) -> Result<Self, Error>
pub fn join_from_existing(existing: &Allocator) -> Result<Self, Error>
Join an existing allocator using the same in-process mapping. Picks the first available worker slot.
Sourcepub fn join_from_existing_free_only(
existing: &FreeOnlyAllocator,
) -> Result<Self, Error>
pub fn join_from_existing_free_only( existing: &FreeOnlyAllocator, ) -> Result<Self, Error>
Join an existing free-only allocator using the same in-process mapping. Picks the first available worker slot.
Source§impl Allocator
impl Allocator
Sourcepub unsafe fn free(&self, ptr: NonNull<u8>)
pub unsafe fn free(&self, ptr: NonNull<u8>)
Free a block of memory previously allocated by this allocator.
§Safety
- The
ptrmust be a valid pointer to a block of memory allocated by this allocator. - The
ptrmust not have been freed before.
Sourcepub unsafe fn free_offset(&self, offset: usize)
pub unsafe fn free_offset(&self, offset: usize)
Free a block of memory previously allocated by this allocator.
§Safety
- The
offsetmust be a valid offset within the memory allocated by this allocator. - The
offsetmust not have been freed before.
Source§impl Allocator
impl Allocator
pub fn outstanding_allocation_bytes(&self) -> u64
Sourcepub fn clean_remote_free_lists(&self)
pub fn clean_remote_free_lists(&self)
Frees all items in remote free lists.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Allocator
impl RefUnwindSafe for Allocator
impl Sync for Allocator
impl Unpin for Allocator
impl UnsafeUnpin for Allocator
impl UnwindSafe for Allocator
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