pub struct Handle { /* private fields */ }Expand description
A thread-safe handle used to schedule work on a runtime.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn current() -> Handle
pub fn current() -> Handle
Returns a handle to the runtime active on the current thread.
§Panics
Panics if no runtime is active on the current thread.
Sourcepub fn notify(&self) -> Result<()>
pub fn notify(&self) -> Result<()>
Wakes the runtime’s driver.
Returns notification errors to the caller without retrying, unlike internal scheduler notifications.
Sourcepub fn busy_duration(&self) -> Option<Duration>
pub fn busy_duration(&self) -> Option<Duration>
Returns the total time the runtime has been busy.
See Runtime::busy_duration. Always returns Some, the return type
matches the other runtime backends.
Sourcepub fn current_turn(&self) -> Option<Duration>
pub fn current_turn(&self) -> Option<Duration>
Returns how long the current runtime turn has been running, None
while the runtime is idle.
Sourcepub fn poll_count(&self) -> Option<u64>
pub fn poll_count(&self) -> Option<u64>
Returns the number of runtime polls that ran scheduled tasks.
See Runtime::poll_count. Always returns Some.
Sourcepub fn poll_again_count(&self) -> Option<u64>
pub fn poll_again_count(&self) -> Option<u64>
Returns the number of runtime polls that left scheduled tasks.
See Runtime::poll_again_count. Always returns Some.
Sourcepub fn self_wake_count(&self) -> Option<u64>
pub fn self_wake_count(&self) -> Option<u64>
Returns the number of times a task woke itself while it was polled.
See Runtime::self_wake_count. Always returns Some.
Sourcepub fn current_task(&self) -> Option<&'static Location<'static>>
pub fn current_task(&self) -> Option<&'static Location<'static>>
Returns the spawn location of the task the runtime is polling.
Returns None while the runtime is idle, handles driver events or
between tasks. Can be read from other threads, for example to name the
task that blocks a stalled runtime.
Sourcepub fn poll_histogram(&self) -> Option<Histogram>
pub fn poll_histogram(&self) -> Option<Histogram>
Returns the histogram of runtime poll durations.
See Runtime::poll_histogram. Always returns Some.
Sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
Spawns a new asynchronous task, returning a JoinHandle for it.
Spawning a task enables the task to execute concurrently to other tasks. There is no guarantee that a spawned task will execute to completion.
The output is moved to the thread that awaits the JoinHandle, so
it must be Send. Use Runtime::spawn for non-Send outputs.
let _ = hnd.spawn(async { std::rc::Rc::new(()) });Sourcepub fn spawn_detached<F>(&self, future: F)
pub fn spawn_detached<F>(&self, future: F)
Spawns a new asynchronous task without a JoinHandle.
The output is dropped on the runtime thread when the task completes,
so it does not have to be Send.