pub trait FrameAllocator<S>where
S: FrameSize,{
// Required methods
fn allocate_n(&self, n: usize) -> Range<Frame<S>>;
fn free_n(&self, start: Frame<S>, n: usize);
// Provided method
fn allocate(&self) -> Frame<S> { ... }
}
Expand description
FrameAllocator
is used to interact with a physical memory manager in a platform-independent way. Methods on
FrameAllocator
take &self
and so are expected to use interior-mutability through a type such as Mutex
to
ensure safe access. This allows structures to store a reference to the allocator, and deallocate memory when
they’re dropped.
A FrameAllocator
is defined for a specific FrameSize
, but multiple implementations of FrameAllocator
(each with a different frame size) can be used for allocators that aren’t tied to a specific block size.
Required Methods§
Sourcefn allocate_n(&self, n: usize) -> Range<Frame<S>>
fn allocate_n(&self, n: usize) -> Range<Frame<S>>
Allocate n
contiguous Frame
s.