pub struct IoHandle { /* private fields */ }Expand description
Copy handle for IO operations from async tasks.
Provides source registration with the mio reactor. Obtained from
IoHandle::current.
§Safety
The raw pointers are valid for the lifetime of the crate::Runtime.
Single-threaded — no concurrent access.
Implementations§
Source§impl IoHandle
impl IoHandle
Sourcepub fn current() -> IoHandle
pub fn current() -> IoHandle
Returns the IoHandle for the currently running runtime.
Use when you need to register a mio source from inside an async task —
e.g., when constructing a TcpStream or
UdpSocket. Mirrors tokio::runtime::Handle::current().
§Panics
Panics if called outside a Runtime::block_on
context.
Sourcepub fn register(
&self,
source: &mut impl Source,
interest: Interest,
waker: Waker,
) -> Result<Token>
pub fn register( &self, source: &mut impl Source, interest: Interest, waker: Waker, ) -> Result<Token>
Register a mio source with the given interest and waker.
Returns the assigned token for use with deregister.
Sourcepub fn set_waker(&self, token: Token, waker: Waker)
pub fn set_waker(&self, token: Token, waker: Waker)
Update the waker for a token. Called when a stream is polled
from a different task than the one that registered it
(e.g., after into_split).
Sourcepub fn readiness(&self, token: Token) -> Readiness
pub fn readiness(&self, token: Token) -> Readiness
Query the readiness state for a token.
Returns the last-known readiness from epoll events. Cleared after the task consumes the readiness (calls clear_readable/clear_writable).
Sourcepub fn clear_readable(&self, token: Token)
pub fn clear_readable(&self, token: Token)
Clear the readable flag for a token. Call after a successful read or WouldBlock to wait for the next epoll notification.
Sourcepub fn clear_writable(&self, token: Token)
pub fn clear_writable(&self, token: Token)
Clear the writable flag for a token.