pub trait AllocablePage {
    const SIZE: usize;
    const METADATA_SIZE: usize;
    const HEAP_ID_OFFSET: usize;
Show 15 methods // Required methods fn new(mp: MappedPages8k, heap_id: usize) -> Self where Self: Sized; fn retrieve_mapped_pages(&mut self) -> Option<MappedPages8k>; fn clear_metadata(&mut self); fn set_heap_id(&mut self, heap_id: usize); fn heap_id(&self) -> usize; fn bitfield(&self) -> &[AtomicU64; 8]; fn bitfield_mut(&mut self) -> &mut [AtomicU64; 8]; fn prev(&mut self) -> &mut Rawlink<Self> where Self: Sized; fn next(&mut self) -> &mut Rawlink<Self> where Self: Sized; fn buffer_size() -> usize; // Provided methods fn first_fit(&self, layout: Layout) -> Option<(usize, usize)> { ... } fn allocate(&mut self, layout: Layout) -> *mut u8 { ... } fn is_full(&self) -> bool { ... } fn is_empty(&self, relevant_bits: usize) -> bool { ... } fn deallocate( &self, ptr: NonNull<u8>, layout: Layout ) -> Result<(), &'static str> { ... }
}
Expand description

This trait is used to define a page from which objects are allocated in an SCAllocator.

The implementor of this trait needs to provide access to the page meta-data, which consists of:

  • MappedPages8k object that owns this memory
  • A bitfield (to track allocations),
  • prev and next pointers to insert the page in free lists

Required Associated Constants§

source

const SIZE: usize

The total size (in bytes) of the page.

Note

We also assume that the address of the page will be aligned to SIZE.

source

const METADATA_SIZE: usize

source

const HEAP_ID_OFFSET: usize

Required Methods§

source

fn new(mp: MappedPages8k, heap_id: usize) -> Selfwhere Self: Sized,

source

fn retrieve_mapped_pages(&mut self) -> Option<MappedPages8k>

source

fn clear_metadata(&mut self)

source

fn set_heap_id(&mut self, heap_id: usize)

source

fn heap_id(&self) -> usize

source

fn bitfield(&self) -> &[AtomicU64; 8]

source

fn bitfield_mut(&mut self) -> &mut [AtomicU64; 8]

source

fn prev(&mut self) -> &mut Rawlink<Self>where Self: Sized,

source

fn next(&mut self) -> &mut Rawlink<Self>where Self: Sized,

source

fn buffer_size() -> usize

Provided Methods§

source

fn first_fit(&self, layout: Layout) -> Option<(usize, usize)>

Tries to find a free block within data that satisfies alignment requirement.

source

fn allocate(&mut self, layout: Layout) -> *mut u8

Tries to allocate an object within this page.

In case the slab is full, returns a null ptr.

source

fn is_full(&self) -> bool

Checks if we can still allocate more objects of a given layout within the page.

source

fn is_empty(&self, relevant_bits: usize) -> bool

Checks if the page has currently no allocations.

source

fn deallocate( &self, ptr: NonNull<u8>, layout: Layout ) -> Result<(), &'static str>

Deallocates a memory object within this page.

Implementors§

source§

impl<'a> AllocablePage for ObjectPage8k<'a>

source§

const SIZE: usize = 8_192usize

source§

const METADATA_SIZE: usize = 128usize

source§

const HEAP_ID_OFFSET: usize = 8_104usize