Skip to main content

Module rt

Module rt 

Source
Expand description

Task and timer facade: tokio natively, the browser event loop on wasm32.

wasm32-unknown-unknown has no threads and no tokio driver, so spawns go to spawn_local and timers to setTimeout. Signatures match tokio’s so call sites read the same on both targets.

Re-exports§

pub use web_time as time_std;

Modules§

time

Structs§

JoinError
Task failed to execute to completion.
JoinHandle
An owned permission to join on a task (await its termination).

Traits§

MaybeSend
Send natively; nothing on wasm32, where there is one thread and browser futures hold !Send JS handles.

Functions§

can_spawn
Whether work can be spawned from here: natively only inside a tokio runtime (a drop off-runtime, or during shutdown, has none); always in the browser, whose event loop is the runtime.
spawn
Spawns a new asynchronous task, returning a JoinHandle for it.
spawn_blocking
Runs the provided closure on a thread where blocking is acceptable.
yield_now
Yields execution back to the Tokio runtime.