Struct a10::io::ReadBufPool
source · pub struct ReadBufPool { /* private fields */ }
Expand description
A read buffer pool.
This is a special buffer pool that shares its buffers with the kernel. The
buffer pool is used by the kernel in read(2)
and recv(2)
like calls.
Instead of user space having to select a buffer before issueing the read
call, the kernel will select a buffer from the pool when it’s ready for
reading. This avoids the need to have as many buffers as concurrent read
calls.
As a result of this the returned buffer, ReadBuf
, is somewhat limited.
For example it can’t grow beyond the pool’s buffer size. However it can be
used in write calls like any other buffer.
Implementations§
source§impl ReadBufPool
impl ReadBufPool
sourcepub fn new(
sq: SubmissionQueue,
pool_size: u16,
buf_size: u32
) -> Result<ReadBufPool>
pub fn new( sq: SubmissionQueue, pool_size: u16, buf_size: u32 ) -> Result<ReadBufPool>
Create a new buffer pool.
pool_size
must be a power of 2, with a maximum of 2^15 (32768).
buf_size
is the maximum capacity of the buffer. Note that buffer can’t
grow beyond this capacity.
sourcepub fn get(&self) -> ReadBuf
pub fn get(&self) -> ReadBuf
Get a buffer reference to this pool.
This can only be used in read I/O operations, such as AsyncFd::read
,
but it won’t yet select a buffer to use. This is done by the kernel once
it actually has data to write into the buffer. Before it’s used in a
read call the returned buffer will be empty and can’t be resized, it’s
effecitvely useless before a read call.
Trait Implementations§
source§impl Clone for ReadBufPool
impl Clone for ReadBufPool
source§fn clone(&self) -> ReadBufPool
fn clone(&self) -> ReadBufPool
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more