Struct driver_net::NetBufferPool
source · pub struct NetBufferPool { /* private fields */ }
Expand description
A pool of NetBuffer
s to speed up buffer allocation.
It divides a large memory into several equal parts for each buffer.
Implementations§
source§impl NetBufferPool
impl NetBufferPool
sourcepub fn new(capacity: usize, buf_len: usize) -> DevResult<Self>
pub fn new(capacity: usize, buf_len: usize) -> DevResult<Self>
Creates a new pool with the given capacity
, and all buffer lengths are
set to buf_len
.
sourcepub const fn buffer_len(&self) -> usize
pub const fn buffer_len(&self) -> usize
Returns the length of each buffer.
sourcepub fn alloc(&self) -> Option<NetBuffer<'_>>
pub fn alloc(&self) -> Option<NetBuffer<'_>>
Allocates a buffer from the pool.
Returns None
if no buffer is available.
sourcepub fn alloc_boxed(&self) -> Option<NetBufferBox<'_>>
pub fn alloc_boxed(&self) -> Option<NetBufferBox<'_>>
Allocates a buffer wrapped in a Box
from the pool.
Returns None
if no buffer is available.
Auto Trait Implementations§
impl !RefUnwindSafe for NetBufferPool
impl Send for NetBufferPool
impl Sync for NetBufferPool
impl Unpin for NetBufferPool
impl UnwindSafe for NetBufferPool
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