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 to a block of memory allocated by this allocator, i.e. an offset returned bySelf::offset. - The
offsetmust not have been freed before.
Source§impl Allocator
impl Allocator
pub fn outstanding_allocation_bytes(&self) -> u64
Sourcepub fn clean_remote_frees(&self)
pub fn clean_remote_frees(&self)
Frees all remotely freed items queued for this worker.
Source§impl Allocator
impl Allocator
Sourcepub fn remote_free_batch(&self) -> RemoteFreeBatch<'_>
pub fn remote_free_batch(&self) -> RemoteFreeBatch<'_>
Create a batch that groups remote frees by owning worker.
Locally owned allocations are reclaimed immediately. Remote frees are
published by RemoteFreeBatch::flush or when the batch is dropped.