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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BufferAllocator
impl RefUnwindSafe for BufferAllocator
impl Send for BufferAllocator
impl Sync for BufferAllocator
impl Unpin for BufferAllocator
impl UnwindSafe for BufferAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more