Struct tokio::runtime::io::scheduled_io::ScheduledIo
source · #[repr(align(128))]pub(crate) struct ScheduledIo {
pub(super) linked_list_pointers: UnsafeCell<Pointers<Self>>,
readiness: AtomicUsize,
waiters: Mutex<Waiters>,
}
Expand description
Stored in the I/O driver resource slab.
Fields§
§linked_list_pointers: UnsafeCell<Pointers<Self>>
§readiness: AtomicUsize
Packs the resource’s readiness and I/O driver latest tick.
waiters: Mutex<Waiters>
Implementations§
source§impl ScheduledIo
impl ScheduledIo
pub(crate) fn token(&self) -> Token
sourcepub(super) fn shutdown(&self)
pub(super) fn shutdown(&self)
Invoked when the IO driver is shut down; forces this ScheduledIo
into a
permanently shutdown state.
sourcepub(super) fn set_readiness(&self, tick_op: Tick, f: impl Fn(Ready) -> Ready)
pub(super) fn set_readiness(&self, tick_op: Tick, f: impl Fn(Ready) -> Ready)
Sets the readiness on this ScheduledIo
by invoking the given closure on
the current value, returning the previous readiness value.
§Arguments
tick
: whether setting the tick or trying to clear readiness for a specific tick.f
: a closure returning a new readiness value given the previous readiness.
sourcepub(super) fn wake(&self, ready: Ready)
pub(super) fn wake(&self, ready: Ready)
Notifies all pending waiters that have registered interest in ready
.
There may be many waiters to notify. Waking the pending task must be done from outside of the lock otherwise there is a potential for a deadlock.
A stack array of wakers is created and filled with wakers to notify, the lock is released, and the wakers are notified. Because there may be more than 32 wakers to notify, if the stack array fills up, the lock is released, the array is cleared, and the iteration continues.
pub(super) fn ready_event(&self, interest: Interest) -> ReadyEvent
sourcepub(super) fn poll_readiness(
&self,
cx: &mut Context<'_>,
direction: Direction,
) -> Poll<ReadyEvent>
pub(super) fn poll_readiness( &self, cx: &mut Context<'_>, direction: Direction, ) -> Poll<ReadyEvent>
Polls for readiness events in a given direction.
These are to support AsyncRead
and AsyncWrite
polling methods,
which cannot use the async fn
version. This uses reserved reader
and writer slots.
pub(crate) fn clear_readiness(&self, event: ReadyEvent)
pub(crate) fn clear_wakers(&self)
source§impl ScheduledIo
impl ScheduledIo
sourcepub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent
pub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent
An async version of poll_readiness
which uses a linked list of wakers.