Skip to main content

Crate effectful_tokio

Crate effectful_tokio 

Source
Expand description

Tokio integration for effectful: TokioRuntime implements effectful::Runtime with cooperative sleep/yield, and runs forked effects on Tokio’s blocking thread pool via tokio::runtime::Handle::spawn_blocking (the Effect interpreter is driven with run_blocking; it is not Send for tokio::spawn).

Tower, Axum, and other Tokio-based adapters should depend on effectful_tokio for this wiring.

§Examples

See examples/ (e.g. 109_tokio_end_to_end). Re-exports run_async, run_blocking, run_fork, and yield_now from effectful for use at the async boundary alongside TokioRuntime.

Structs§

TokioRuntime
Tokio-backed Runtime adapter (async sleep / yield_now).
YieldNow
Zero-allocation yield token for use in effect! macros.

Enums§

EffectExecution
Execution mode for run_effect_from_state_with.

Functions§

run_async
Commonly used at the async boundary together with TokioRuntime. Run an effect to completion using the async executor (.await on Effect::run).
run_blocking
Commonly used at the async boundary together with TokioRuntime. Run an effect to completion on the current thread using a tight poll loop.
run_effect_from_state
Convenience wrapper: run_effect_from_state_with with EffectExecution::Plain.
run_effect_from_state_with
Run build(&mut env) to obtain an effect, then drive it to completion with the same env.
run_fork
Commonly used at the async boundary together with TokioRuntime. Spawn a fiber using runtime (delegates to Runtime::spawn_with).
yield_now
Commonly used at the async boundary together with TokioRuntime. Cooperative yield via runtime (delegates to Runtime::yield_now).