Struct a10::SubmissionQueue

source ·
pub struct SubmissionQueue { /* private fields */ }
Expand description

Queue to submit asynchronous operations to.

This type doesn’t have many public methods, but is used by all I/O types, such as OpenOptions, to queue asynchronous operations. The queue can be acquired by using Ring::submission_queue.

The submission queue can be shared by cloning it, it’s a cheap operation.

Implementations§

source§

impl SubmissionQueue

source

pub fn wake(&self)

Wake the connected Ring.

All this does is interrupt a call to Ring::poll.

source

pub fn msg_listener(self) -> Result<(MsgListener, MsgToken)>

Setup a listener for user space messages.

The returned MsgListener iterator will return all messages send using SubmissionQueue::try_send_msg and SubmissionQueue::send_msg using the returned MsgToken.

§Notes

This will return an error if too many operations are already queued, this is usually resolved by calling Ring::poll.

The returned MsgToken has an implicitly lifetime linked to MsgListener. If MsgListener is dropped the MsgToken will become invalid.

Due to the limitations mentioned above it’s advised to consider the usefulness of the type severly limited. The returned MsgListener iterator should live for the entire lifetime of the Ring, to ensure we don’t use MsgToken after it became invalid. Furthermore to ensure the creation of it succeeds it should be done early in the lifetime of Ring.

source

pub fn try_send_msg(&self, token: MsgToken, data: u32) -> Result<()>

Try to send a message to iterator listening for message using MsgToken.

This will use the io_uring submission queue to share data with the receiving end. This means that it will wake up the thread if it’s currently polling.

This will fail if the submission queue is currently full. See SubmissionQueue::send_msg for a version that tries again when the submission queue is full.

See SubmissionQueue::msg_listener for examples.

source

pub const fn send_msg<'a>(&'a self, token: MsgToken, data: u32) -> SendMsg<'a>

Send a message to iterator listening for message using MsgToken.

source

pub fn oneshot_poll<'a>( &'a self, fd: BorrowedFd<'_>, mask: c_int ) -> OneshotPoll<'a>

Wait for an event specified in mask on the file descriptor fd.

Ths is similar to calling poll(2) the file descriptor.

source

pub fn multishot_poll<'a>( &'a self, fd: BorrowedFd<'_>, mask: c_int ) -> MultishotPoll<'a>

Returns an AsyncIterator that returns multiple events as specified in mask on the file descriptor fd.

This is not the same as calling SubmissionQueue::oneshot_poll in a loop as this uses a multishot operation, which means only a single operation is created kernel side, making this more efficient.

Trait Implementations§

source§

impl Clone for SubmissionQueue

source§

fn clone(&self) -> SubmissionQueue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SubmissionQueue

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.