pub struct Ring<T, E: RingOp<T>> { /* private fields */ }Expand description
An io_uring instance.
Implementations§
Source§impl<T, E: RingOp<T>> Ring<T, E>
impl<T, E: RingOp<T>> Ring<T, E>
Sourcepub fn new(ring: IoUring, ctx: T) -> Self
pub fn new(ring: IoUring, ctx: T) -> Self
Creates a new ring with the provided io_uring instance and context.
The context T is a user defined value that will be passed to entries E once they
complete. This value can be used to update state or perform additional actions as operations
complete asynchronously.
Sourcepub fn context_mut(&mut self) -> &mut T
pub fn context_mut(&mut self) -> &mut T
Returns a mutable reference to the context value.
Sourcepub unsafe fn register_buffers(&self, iovecs: &[iovec]) -> Result<()>
pub unsafe fn register_buffers(&self, iovecs: &[iovec]) -> Result<()>
Registers in-memory fixed buffers for I/O with the kernel.
§Safety
Callers must ensure that the iov_base and iov_len values are valid and will be valid until buffers are unregistered or the ring destroyed, otherwise undefined behaviour may occur.
Sourcepub fn push(&mut self, op: E) -> Result<()>
pub fn push(&mut self, op: E) -> Result<()>
Pushes an operation to the submission queue.
Once completed, RingOp::complete will be called with the result.
Note that the operation is not submitted to the kernel until Ring::submit is called. If the submission queue is full, submit will be called internally to make room for the new operation.
See also Ring::submit.
Sourcepub fn submit(&mut self) -> Result<()>
pub fn submit(&mut self) -> Result<()>
Submits all pending operations to the kernel.
If the ring can’t accept any more submissions because the completion queue is full, this will process completions and retry until the submissions are accepted.
See also Ring::process_completions.
Sourcepub fn submit_and_wait(
&mut self,
want: usize,
timeout: Option<Duration>,
) -> Result<usize>
pub fn submit_and_wait( &mut self, want: usize, timeout: Option<Duration>, ) -> Result<usize>
Submits all pending operations to the kernel and waits for completions.
If no timeout is passed this will block until want completions are available. If a
timeout is passed, this will block until want completions are available or the timeout is
reached.
Returns the number of completions received.
Sourcepub fn process_completions(&mut self) -> Result<()>
pub fn process_completions(&mut self) -> Result<()>
Processes completions from the kernel.
This will process all completions currently available in the completion queue and invoke RingOp::complete for each completed operation.