Struct Allocator

Source
pub struct Allocator { /* private fields */ }

Implementations§

Source§

impl Allocator

Source

pub fn create( path: impl AsRef<Path>, file_size: usize, num_workers: u32, slab_size: u32, worker_index: u32, ) -> Result<Self, Error>

Create a new Allocator with new file and given parameters.

Source

pub fn join(path: impl AsRef<Path>, worker_index: u32) -> Result<Self, Error>

Join an existing allocator at the given path.

§Safety
  • worker_index must be uniquely assigned to this worker thread/process.
Source§

impl Allocator

Source

pub fn allocate(&self, size: u32) -> Option<NonNull<u8>>

Allocates a block of memory of the given size. If the size is larger than the maximum size class, returns None. If the allocation fails, returns None.

Source§

impl Allocator

Source

pub unsafe fn free(&self, ptr: NonNull<u8>)

Free a block of memory previously allocated by this allocator.

§Safety
  • The ptr must be a valid pointer to a block of memory allocated by this allocator.
  • The ptr must not have been freed before.
Source

pub unsafe fn offset(&self, ptr: NonNull<u8>) -> usize

Find the offset given a pointer.

§Safety
  • The ptr must be a valid pointer in the allocator’s address space.
Source

pub fn ptr_from_offset(&self, offset: usize) -> NonNull<u8>

Return a ptr given a shareable offset - calculated by offset.

Source§

impl Allocator

Source

pub fn clean_remote_free_lists(&self)

Frees all items in remote free lists.

Trait Implementations§

Source§

impl Drop for Allocator

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.