[−][src]Struct iou::IoUring
The main interface to kernel IO using io_uring
.
IoUring
is a high-level wrapper around an io_uring
object.
IoUring
s are constructed with a requested number of ring buffer entries and possibly a set of
SetupFlags
. Allocations for IoUring
are memlocked
and will not be paged
out.
// make a IoUring with 16 entries let mut ring = IoUring::new(16)?; // make a IoUring set to poll the IO context let mut ring = IoUring::new_with_flags(32, SetupFlags::IOPOLL, SetupFeatures::empty())?;
IoUring
s can either be used directly, or split into separate parts and
operated on without synchronization.
// split an IoUring piecewise let sq: SubmissionQueue = ring.sq(); let cq: CompletionQueue = ring.cq(); let reg: Registrar = ring.registrar(); // split an IoUring into its three parts all at once let (sq, cq, reg) = ring.queues();
Implementations
impl IoUring
[src]
pub fn new(entries: u32) -> Result<IoUring>
[src]
Creates a new IoUring
without any setup flags. IoUring
's created using this method will
use interrupt-driven IO.
The number of entries must be in the range of 1..4096 (inclusive) and it's recommended to be a power of two.
The underlying SubmissionQueue
and CompletionQueue
will each have this number of
entries.
pub fn new_with_flags(
entries: u32,
flags: SetupFlags,
features: SetupFeatures
) -> Result<IoUring>
[src]
entries: u32,
flags: SetupFlags,
features: SetupFeatures
) -> Result<IoUring>
Creates a new IoUring
using a set of SetupFlags
and SetupFeatures
for advanced
use cases.
pub fn sq(&mut self) -> SubmissionQueue<'_>
[src]
Returns the SubmissionQueue
part of the IoUring
.
pub fn cq(&mut self) -> CompletionQueue<'_>
[src]
Returns the CompletionQueue
part of the IoUring
.
pub fn registrar(&self) -> Registrar<'_>
[src]
Returns the Registrar
part of the IoUring
.
pub fn queues(
&mut self
) -> (SubmissionQueue<'_>, CompletionQueue<'_>, Registrar<'_>)
[src]
&mut self
) -> (SubmissionQueue<'_>, CompletionQueue<'_>, Registrar<'_>)
Returns the three constituent parts of the IoUring
.
pub fn probe(&mut self) -> Result<Probe>
[src]
pub fn prepare_sqe(&mut self) -> Option<SQE<'_>>
[src]
Returns the next SQE
which can be prepared to submit.
pub fn prepare_sqes(&mut self, count: u32) -> Option<SQEs<'_>>
[src]
Returns the next count
SQE
s which can be prepared to submit as an iterator.
See the SQEs
type for more information about how these multiple SQEs can be used.
pub fn submit_sqes(&mut self) -> Result<u32>
[src]
Submit all prepared SQE
s to the kernel.
pub fn submit_sqes_and_wait(&mut self, wait_for: u32) -> Result<u32>
[src]
Submit all prepared SQE
s to the kernel and wait until at least wait_for
events have
completed.
pub fn submit_sqes_and_wait_with_timeout(
&mut self,
wait_for: u32,
duration: Duration
) -> Result<u32>
[src]
&mut self,
wait_for: u32,
duration: Duration
) -> Result<u32>
Submit all prepared SQE
s to the kernel and wait until at least wait_for
events have
completed or duration
has passed.
pub fn peek_for_cqe(&mut self) -> Option<CQE>
[src]
Peek for any CQE
that is already completed, without blocking. This will consume that
CQE.
pub fn wait_for_cqe(&mut self) -> Result<CQE>
[src]
Block until at least one CQE
is completed. This will consume that CQE.
pub fn wait_for_cqe_with_timeout(&mut self, duration: Duration) -> Result<CQE>
[src]
Block until a CQE
is ready or timeout.
pub fn cqes(&mut self) -> CQEs<'_>ⓘ
[src]
Returns an iterator of CQE
s which are ready from the kernel.
pub fn cqes_blocking(&mut self, count: u32) -> CQEsBlocking<'_>ⓘNotable traits for CQEsBlocking<'_>
impl<'_> Iterator for CQEsBlocking<'_> type Item = Result<CQE>;
[src]
Notable traits for CQEsBlocking<'_>
impl<'_> Iterator for CQEsBlocking<'_> type Item = Result<CQE>;
Returns an iterator of CQE
s which will block when there are no CQEs ready. It will
block until at least count
are ready, and then continue iterating.
This iterator will never be exhausted; every time it runs out of CQEs it will block the thread and wait for more to be ready.
pub fn wait_for_cqes(&mut self, count: u32) -> Result<()>
[src]
Wait until count
CQE
s are ready, without submitting any events.
pub fn raw(&self) -> &io_uring
[src]
pub unsafe fn raw_mut(&mut self) -> &mut io_uring
[src]
pub fn cq_ready(&mut self) -> u32
[src]
pub fn sq_ready(&mut self) -> u32
[src]
pub fn sq_space_left(&mut self) -> u32
[src]
pub fn cq_eventfd_enabled(&mut self) -> bool
[src]
pub fn cq_eventfd_toggle(&mut self, enabled: bool) -> Result<()>
[src]
pub fn raw_fd(&self) -> RawFd
[src]
Trait Implementations
impl Debug for IoUring
[src]
impl Drop for IoUring
[src]
impl Send for IoUring
[src]
impl Sync for IoUring
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,