pub struct BufPool { /* private fields */ }Expand description
A pool of byte buffers in size classes. See the module docs.
Implementations§
Source§impl BufPool
impl BufPool
Sourcepub fn new(classes: [usize; 3], max_cached: usize) -> BufPool
pub fn new(classes: [usize; 3], max_cached: usize) -> BufPool
A pool with the given class sizes (ascending) and at most max_cached buffers kept per
class (the larger classes keep a quarter and a sixteenth of that).
Sourcepub fn get(&mut self, min: usize) -> Vec<u8> ⓘ
pub fn get(&mut self, min: usize) -> Vec<u8> ⓘ
An empty buffer with capacity of at least min bytes: the smallest class that fits, or
exactly min when it is larger than every class.
Sourcepub fn put(&mut self, buf: Vec<u8>)
pub fn put(&mut self, buf: Vec<u8>)
Takes a buffer back. It is cleared and kept if its capacity is a class size and that class is not full; otherwise it is freed. Out of line: it is called from many places in the loop, and a call costs nothing next to the free or push it ends in.
Trait Implementations§
Auto Trait Implementations§
impl Forget for BufPool
impl Freeze for BufPool
impl Move for BufPool
impl RefUnwindSafe for BufPool
impl Send for BufPool
impl Sync for BufPool
impl Unpin for BufPool
impl UnsafeUnpin for BufPool
impl UnwindSafe for BufPool
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