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
impl SubmissionQueue
sourcepub fn wake(&self)
pub fn wake(&self)
Wake the connected Ring
.
All this does is interrupt a call to Ring::poll
.
sourcepub fn msg_listener(self) -> Result<(MsgListener, MsgToken)>
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
.
sourcepub fn try_send_msg(&self, token: MsgToken, data: u32) -> Result<()>
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.
sourcepub const fn send_msg<'a>(&'a self, token: MsgToken, data: u32) -> SendMsg<'a> ⓘ
pub const fn send_msg<'a>(&'a self, token: MsgToken, data: u32) -> SendMsg<'a> ⓘ
Send a message to iterator listening for message using MsgToken
.
sourcepub fn oneshot_poll<'a>(
&'a self,
fd: BorrowedFd<'_>,
mask: c_int
) -> OneshotPoll<'a> ⓘ
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.
sourcepub fn multishot_poll<'a>(
&'a self,
fd: BorrowedFd<'_>,
mask: c_int
) -> MultishotPoll<'a>
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
impl Clone for SubmissionQueue
source§fn clone(&self) -> SubmissionQueue
fn clone(&self) -> SubmissionQueue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more