pub struct IoUring<S = Entry, C = Entry>where
S: EntryMarker,
C: EntryMarker,{ /* private fields */ }
Expand description
IoUring instance
S
: The ring’s submission queue entry (SQE) type, eithersqueue::Entry
orsqueue::Entry128
;C
: The ring’s completion queue entry (CQE) type, eithercqueue::Entry
orcqueue::Entry32
.
Implementations§
Source§impl IoUring<Entry, Entry>
impl IoUring<Entry, Entry>
Sourcepub fn new(entries: u32) -> Result<Self>
pub fn new(entries: u32) -> Result<Self>
Create a new IoUring
instance with default configuration parameters. See Builder
to
customize it further.
The entries
sets the size of queue,
and its value should be the power of two.
Sourcepub unsafe fn from_fd(fd: RawFd, params: Parameters) -> Result<Self>
pub unsafe fn from_fd(fd: RawFd, params: Parameters) -> Result<Self>
Create an IoUring
instance from a pre-opened file descriptor.
§Safety
The caller must uphold that the file descriptor is owned and refers to a uring. The
params
argument must be equivalent to the those previously filled in by the kernel when
the provided ring was created.
Source§impl<S: EntryMarker, C: EntryMarker> IoUring<S, C>
impl<S: EntryMarker, C: EntryMarker> IoUring<S, C>
Sourcepub fn builder() -> Builder<S, C>
pub fn builder() -> Builder<S, C>
Create a Builder
for an IoUring
instance.
This allows for further customization than new
.
Unlike IoUring::new
, this function is available for any combination of submission
queue entry (SQE) and completion queue entry (CQE) types.
Sourcepub fn submitter(&self) -> Submitter<'_>
pub fn submitter(&self) -> Submitter<'_>
Get the submitter of this io_uring instance, which can be used to submit submission queue events to the kernel for execution and to register files or buffers with it.
Sourcepub fn params(&self) -> &Parameters
pub fn params(&self) -> &Parameters
Get the parameters that were used to construct this instance.
Sourcepub fn submit(&self) -> Result<usize>
pub fn submit(&self) -> Result<usize>
Initiate asynchronous I/O. See Submitter::submit
for more details.
Sourcepub fn submit_and_wait(&self, want: usize) -> Result<usize>
pub fn submit_and_wait(&self, want: usize) -> Result<usize>
Initiate and/or complete asynchronous I/O. See Submitter::submit_and_wait
for more
details.
Sourcepub fn split(
&mut self,
) -> (Submitter<'_>, SubmissionQueue<'_, S>, CompletionQueue<'_, C>)
pub fn split( &mut self, ) -> (Submitter<'_>, SubmissionQueue<'_, S>, CompletionQueue<'_, C>)
Get the submitter, submission queue and completion queue of the io_uring instance. This can be used to operate on the different parts of the io_uring instance independently.
If you use this method to obtain sq
and cq
,
please note that you need to drop
or sync
the queue before and after submit,
otherwise the queue will not be updated.
Sourcepub fn submission(&mut self) -> SubmissionQueue<'_, S>
pub fn submission(&mut self) -> SubmissionQueue<'_, S>
Get the submission queue of the io_uring instance. This is used to send I/O requests to the kernel.
Get the submission queue of the io_uring instance from a shared reference.
§Safety
No other SubmissionQueue
s may exist when calling this function.
Sourcepub fn completion(&mut self) -> CompletionQueue<'_, C> ⓘ
pub fn completion(&mut self) -> CompletionQueue<'_, C> ⓘ
Get completion queue of the io_uring instance. This is used to receive I/O completion events from the kernel.
Get the completion queue of the io_uring instance from a shared reference.
§Safety
No other CompletionQueue
s may exist when calling this function.