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§
- Tokio
Runtime - Tokio-backed
Runtimeadapter (asyncsleep/yield_now). - Yield
Now - Zero-allocation yield token for use in
effect!macros.
Enums§
- Effect
Execution - 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 (.awaitonEffect::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_withwithEffectExecution::Plain. - run_
effect_ from_ state_ with - Run
build(&mut env)to obtain an effect, then drive it to completion with the sameenv. - run_
fork - Commonly used at the async boundary together with
TokioRuntime. Spawn a fiber usingruntime(delegates toRuntime::spawn_with). - yield_
now - Commonly used at the async boundary together with
TokioRuntime. Cooperative yield viaruntime(delegates toRuntime::yield_now).