pub struct Ring { /* private fields */ }Expand description
This type represents the user space side of an io_uring.
An io_uring is split into two queues: the submissions and completions queue.
The SubmissionQueue is public, but doesn’t provide many methods. The
SubmissionQueue is used by I/O types in the crate to schedule asynchronous
operations.
The completions queue is not exposed by the crate and only used internally.
Instead it will wake the Futures exposed by the various I/O types, such
as AsyncFd::write’s Write Future.
Implementations§
Source§impl Ring
io_uring specific methods.
impl Ring
io_uring specific methods.
Sourcepub fn enable(&mut self) -> Result<()>
pub fn enable(&mut self) -> Result<()>
Enable the ring.
This only required when starting the ring in disabled mode, see
Config::disable.
Source§impl Ring
impl Ring
Sourcepub const fn config<'r>(queued_operations: usize) -> Config<'r>
pub const fn config<'r>(queued_operations: usize) -> Config<'r>
Configure a Ring.
queued_operations is the number of queued operations, i.e. the number
of concurrent A10 operation.
§Notes
A10 uses IORING_SETUP_SQPOLL by default for io_uring, which required
Linux kernel 5.11 to work correctly. Furthermore before Linux 5.13 the
user needs the CAP_SYS_NICE capability if run as non-root. This can be
disabled by Config::with_kernel_thread.
Sourcepub fn new(queued_operations: usize) -> Result<Ring>
pub fn new(queued_operations: usize) -> Result<Ring>
Create a new Ring with the default configuration.
For more configuration options see Config.
Sourcepub const fn sq(&self) -> &SubmissionQueue
pub const fn sq(&self) -> &SubmissionQueue
Returns the SubmissionQueue used by this ring.
The SubmissionQueue can be used to queue asynchronous I/O operations.
Sourcepub fn poll(&mut self, timeout: Option<Duration>) -> Result<()>
pub fn poll(&mut self, timeout: Option<Duration>) -> Result<()>
Poll the ring for completions.
This will wake all completed Futures with the result of their
operations.
If a zero duration timeout (i.e. Some(Duration::ZERO)) is passed this
function will only wake all already completed operations. When using
io_uring it also guarantees to not make a system call, but it also means
it doesn’t guarantee at least one completion was processed.