Struct tokio_uring::Builder
source · pub struct Builder { /* private fields */ }
Expand description
Builder API to allow starting the runtime and creating the io_uring driver with non-default parameters.
Implementations§
source§impl Builder
impl Builder
sourcepub fn entries(&mut self, e: u32) -> &mut Self
pub fn entries(&mut self, e: u32) -> &mut Self
Set number of submission queue entries in uring.
The kernel will ensure it uses a power of two and will round this up if necessary. The kernel requires the number of completion queue entries to be larger than the submission queue entries so generally will double the sq entries count.
The caller can specify even a larger cq entries count by using the uring_builder as shown in the start example below.
sourcepub fn uring_builder(&mut self, b: &Builder) -> &mut Self
pub fn uring_builder(&mut self, b: &Builder) -> &mut Self
Replace the default io_uring Builder. This allows the caller to craft the io_uring Builder using the io_uring crate’s Builder API.
Refer to the Builder start method for an example. 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
Start 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
}
}
)
}