SubmissionQueue

Struct SubmissionQueue 

Source
pub struct SubmissionQueue<'ring> { /* private fields */ }
Expand description

The queue of pending IO events.

Each element is a SQE. By default, events are processed in parallel after being submitted. You can modify this behavior for specific events using event SubmissionFlags.

§Examples

Consider a read event that depends on a successful write beforehand.

We reify this relationship by using IO_LINK to link these events.

let mut write_event = sq.prepare_sqe().unwrap();

// -- write event prep elided

// set IO_LINK to link the next event to this one
write_event.set_flags(SubmissionFlags::IO_LINK);

let mut read_event = sq.prepare_sqe().unwrap();

// -- read event prep elided

// read_event only occurs if write_event was successful
sq.submit()?;

Implementations§

Source§

impl<'ring> SubmissionQueue<'ring>

Source

pub fn prepare_sqe<'a>(&'a mut self) -> Option<SQE<'a>>

Returns new SQEs until the queue size is reached. After that, will return None.

let mut ring = IoUring::new(ring_size)?;

let mut counter = 0;

while let Some(event) = ring.prepare_sqe() {
    counter += 1;
}

assert_eq!(counter, ring_size);
assert!(ring.prepare_sqe().is_none());
Source

pub fn prepare_sqes<'a>(&'a mut self, count: u32) -> Option<SQEs<'a>>

Source

pub fn submit(&mut self) -> Result<u32>

Submit all events in the queue. Returns the number of submitted events.

If this function encounters any IO errors an io::Error variant is returned.

Source

pub fn submit_and_wait(&mut self, wait_for: u32) -> Result<u32>

Source

pub fn submit_and_wait_with_timeout( &mut self, wait_for: u32, duration: Duration, ) -> Result<u32>

Source

pub fn ready(&self) -> u32

Source

pub fn space_left(&self) -> u32

Trait Implementations§

Source§

impl Debug for SubmissionQueue<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'ring> Send for SubmissionQueue<'ring>

Source§

impl<'ring> Sync for SubmissionQueue<'ring>

Auto Trait Implementations§

§

impl<'ring> Freeze for SubmissionQueue<'ring>

§

impl<'ring> RefUnwindSafe for SubmissionQueue<'ring>

§

impl<'ring> Unpin for SubmissionQueue<'ring>

§

impl<'ring> !UnwindSafe for SubmissionQueue<'ring>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.