Expand description
task module provides helper functions for use with async closures that operate uniformly
in native (tokio-backed) and WASM
(wasm-bindgen-futures-backed) environments
(i.e. a web browser).
Following functions are are available:
spawn()- non-blocking spawn of the supplied async closuresleep()- suspends the task for a given Durationyield_now()- yields rust executoryield_executor()- yields to top-level executor (browser async loop)
Blocking spawn is not available as a part of this framework as WASM-browser environment can not block task execution due to a single-threaded async application environment.
Modules§
- wasm
- WASM implementation
Macros§
- call_
async_ no_ send - Awaits an
asyncblock orawaitexpression whose future is notSendby dispatching it onto a local task and relaying the result back through a oneshot channel wrapped inSendable. Accepts either an async block or an await expression and propagates errors with?.
Structs§
- Interval
Intervalstream used by theinterval()function to provide a a time interval stream. The stream is backed by tokio interval stream on native platforms and by by the JavaScriptsetInterval()andclearInterval()APIs in WASM32 environment.
Functions§
- dispatch
- Not supported on native targets; provided for API parity with the WASM implementation and never reached.
- interval
async interval()function backed by the JavaScriptcreateInterval()- sleep
- Waits until
durationhas elapsed. - spawn
- Spawns a
Sendfuture onto the tokio runtime, detaching the resulting task. - yield_
executor - Yields execution back to the Tokio runtime.
- yield_
now - Yields execution back to the Tokio runtime.