Struct tokio::io::bsd::Aio

source ·
pub struct Aio<E> { /* private fields */ }
Available on FreeBSD and crate feature net only.
Expand description

Associates a POSIX AIO control block with the reactor that drives it.

Aio’s wrapped type must implement AioSource to be driven by the reactor.

The wrapped source may be accessed through the Aio via the Deref and DerefMut traits.

§Clearing readiness

If Aio::poll_ready returns ready, but the consumer determines that the Source is not completely ready and must return to the Pending state, Aio::clear_ready may be used. This can be useful with lio_listio, which may generate a kevent when only a portion of the operations have completed.

§Platforms

Only FreeBSD implements POSIX AIO with kqueue notification, so Aio is only available for that operating system.

Implementations§

source§

impl<E: AioSource> Aio<E>

source

pub fn new_for_aio(io: E) -> Result<Self>

Creates a new Aio suitable for use with POSIX AIO functions.

It will be associated with the default reactor. The runtime is usually set implicitly when this function is called from a future driven by a Tokio runtime, otherwise runtime can be set explicitly with Runtime::enter function.

source

pub fn new_for_lio(io: E) -> Result<Self>

Creates a new Aio suitable for use with lio_listio.

It will be associated with the default reactor. The runtime is usually set implicitly when this function is called from a future driven by a Tokio runtime, otherwise runtime can be set explicitly with Runtime::enter function.

source

pub fn clear_ready(&self, ev: AioEvent)

Indicates to Tokio that the source is no longer ready. The internal readiness flag will be cleared, and tokio will wait for the next edge-triggered readiness notification from the OS.

It is critical that this method not be called unless your code actually observes that the source is not ready. The OS must deliver a subsequent notification, or this source will block forever. It is equally critical that you do call this method if you resubmit the same structure to the kernel and poll it again.

This method is not very useful with AIO readiness, since each aiocb structure is typically only used once. It’s main use with lio_listio, which will sometimes send notification when only a portion of its elements are complete. In that case, the caller must call clear_ready before resubmitting it.

source

pub fn into_inner(self) -> E

Destroy the Aio and return its inner source.

source

pub fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<AioEvent>>

Polls for readiness. Either AIO or LIO counts.

This method returns:

  • Poll::Pending if the underlying operation is not complete, whether or not it completed successfully. This will be true if the OS is still processing it, or if it has not yet been submitted to the OS.
  • Poll::Ready(Ok(_)) if the underlying operation is complete.
  • Poll::Ready(Err(_)) if the reactor has been shutdown. This does not indicate that the underlying operation encountered an error.

When the method returns Poll::Pending, the Waker in the provided Context is scheduled to receive a wakeup when the underlying operation completes. Note that on multiple calls to poll_ready, only the Waker from the Context passed to the most recent call is scheduled to receive a wakeup.

Trait Implementations§

source§

impl<E: AioSource + Debug> Debug for Aio<E>

source§

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

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

impl<E: AioSource> Deref for Aio<E>

§

type Target = E

The resulting type after dereferencing.
source§

fn deref(&self) -> &E

Dereferences the value.
source§

impl<E: AioSource> DerefMut for Aio<E>

source§

fn deref_mut(&mut self) -> &mut E

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<E> Freeze for Aio<E>
where E: Freeze,

§

impl<E> !RefUnwindSafe for Aio<E>

§

impl<E> Send for Aio<E>
where E: Send,

§

impl<E> Sync for Aio<E>
where E: Sync,

§

impl<E> Unpin for Aio<E>
where E: Unpin,

§

impl<E> !UnwindSafe for Aio<E>

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more