pub struct Builder { /* private fields */ }Expand description
Builder API that can create and start the io_uring runtime with non-default parameters,
while abstracting away the underlying io_uring crate.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn entries(&mut self, sq_entries: u32) -> &mut Self
pub fn entries(&mut self, sq_entries: u32) -> &mut Self
Sets the number of Submission Queue entries in uring.
The default value is 256.
The kernel requires the number of submission queue entries to be a power of two,
and that it be less than the number of completion queue entries.
This function will adjust the cq_entries value to be at least 2 times sq_entries
Sourcepub fn uring_builder(&mut self, b: &Builder) -> &mut Self
pub fn uring_builder(&mut self, b: &Builder) -> &mut Self
Replaces the default io_uring::Builder, which controls the settings for the
inner io_uring API.
Refer to the io_uring::Builder documentation for all the supported methods.
Sourcepub fn start<F: Future>(&self, future: F) -> F::Output
pub fn start<F: Future>(&self, future: F) -> F::Output
Starts an io_uring enabled Tokio runtime.
§Examples
Creating a uring driver with only 64 submission queue entries but many more completion queue entries.
use tokio::net::TcpListener;
fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio_uring::builder()
.entries(64)
.uring_builder(tokio_uring::uring_builder()
.setup_cqsize(1024)
)
.start(async {
let listener = TcpListener::bind("127.0.0.1:8080").await?;
loop {
let (socket, _) = listener.accept().await?;
// process socket
}
}
)
}