Module workflow_core::task

source ·
Expand description

task module provides helper functions for use with async closures that operate uniformly in native (tokio-backed) and WASM (async_std-backed) environments (i.e. a web browser).

Following functions are are available:

  • spawn() - non-blocking spawn of the supplied async closure
  • sleep() - suspends the task for a given Duration
  • yield_now() - yields rust executor
  • yield_executor() - yields to top-level executor (browser async loop)

A Task struct is also available and allows spawning an async closures while providing it with an argument, a return value and a channel that signals termination. Once started, the task can be externally terminated and/or waited until completion.

Blocking spawn is not available as browser-WASM can
not block task execution due to a single-threaded async environment.

Re-exports

pub use native::*;

Modules

native implementation
WASM implementation