pub struct BufferPool { /* private fields */ }Expand description
A worker’s buffer pool: free lists per size class, drawing new buffers from a budget shared by every worker of a server.
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn standalone(bytes: u64) -> BufferPool
pub fn standalone(bytes: u64) -> BufferPool
A pool with its own budget of bytes, for use outside a server.
let mut pool = net_io::BufferPool::standalone(64 * 1024);
assert!(pool.take(net_io::SizeClass::LARGE).is_some());
assert!(pool.take(net_io::SizeClass::LARGE).is_none()); // budget spentSourcepub fn take(&mut self, class: SizeClass) -> Option<Buffer>
pub fn take(&mut self, class: SizeClass) -> Option<Buffer>
A buffer of class, or None when the free list is empty and the budget is spent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl UnwindSafe for BufferPool
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