Expand description
Timers and clocks that work the same on a host and in a browser:
tokio’s timer and std::time on a host, the browser’s setTimeout
and performance.now() under wasm32-unknown-unknown, where
std::time::Instant::now and tokio’s timer driver are unavailable.
Structs§
- Aborted
- The task was aborted before it finished.
- Elapsed
- A deadline passed before the future finished.
- Instant
- A monotonic instant: tokio’s on a host, so a paused test clock moves
it;
performance.now()in a browser. A measurement of a monotonically nondecreasing clock. Opaque and useful only withDuration. - System
Time - A measurement of the system clock, useful for talking to external entities like the file system or other processes.
- Task
- A background task that can be awaited or aborted, on either target.
Dropping it detaches the task, which runs on, as tokio’s
JoinHandledoes.
Constants§
- UNIX_
EPOCH - An anchor in time which can be used to create new
SystemTimeinstances or learn about where in time aSystemTimelies.
Traits§
- Maybe
Send Sendon a host; nothing in a browser, where values that touch JavaScript stay on the thread that made them. Bound a future or stream by it where a host needsSendand a browser cannot give it.
Functions§
- sleep
- Wait for
duration. - spawn
- Run
futurein the background: on tokio’s runtime on a host, on the browser’s event loop in a browser. - spawn_
task - Run
futurein the background, asspawndoes, keeping a handle to await or abort it. - timeout
future’s output, unlessdurationpasses first.