pub struct BufferAllocator { /* private fields */ }Expand description
BufferAllocator creates Buffer objects to be used for block device I/O requests.
This is implemented through a simple buddy allocation scheme.
Implementations§
Source§impl BufferAllocator
impl BufferAllocator
pub fn new(block_size: usize, source: BufferSource) -> Self
pub fn block_size(&self) -> usize
pub fn buffer_source(&self) -> &BufferSource
Sourcepub fn take_buffer_source(self) -> BufferSource
pub fn take_buffer_source(self) -> BufferSource
Takes the buffer source from the allocator and consumes the allocator.
Sourcepub fn allocate_buffer(&self, size: usize) -> BufferFuture<'_> ⓘ
pub fn allocate_buffer(&self, size: usize) -> BufferFuture<'_> ⓘ
Allocates a Buffer with capacity for |size| bytes. Panics if the allocation exceeds the pool size. Blocks until there are enough bytes available to satisfy the request.
The allocated buffer will be block-aligned and the padding up to block alignment can also be used by the buffer.
Allocation is O(lg(N) + M), where N = size and M = number of allocations.
Sourcepub fn try_allocate_buffer(
&self,
size: usize,
) -> Result<Buffer<'_>, EventListener>
pub fn try_allocate_buffer( &self, size: usize, ) -> Result<Buffer<'_>, EventListener>
Like |allocate_buffer|, but returns an EventListener if the allocation cannot be satisfied. The listener will signal when the caller should try again.
Sourcepub fn clean_transfer_buffer(&self)
pub fn clean_transfer_buffer(&self)
Zeroes out all unnallocated ranges in the transfer buffer.