Skip to main content

Crate teksilo_async_std

Crate teksilo_async_std 

Source
Expand description

§teksilo-async-std — async-std reactor for Teksilo’s async executor

Thin adapter over teksilo-async. Unlike Tokio, async-std runs a global reactor that starts lazily on first use, so no per-tick runtime-context guard is needed: install_async_async_std() is exactly install_async plus the async-std dependency in the tree. Native async-std futures (async_std::task::sleep, async-std sockets, …) can be .awaited directly inside ctx.spawn_local(...) bodies — when a leaf future is ready, the global reactor wakes the executor’s Waker and the loop ticks again.

use teksilo_async_std::TeksiloAppBuilderAsyncStdExt;
TeksiloAppBuilder::new().install_async_async_std() /* ... */ .run();

ctx.spawn_local(async move {
    async_std::task::sleep(std::time::Duration::from_secs(1)).await;
    status.set("done".into());
})
.detach();

Structs§

TaskHandle
Handle to a spawned task. Dropping it cancels the task (the future is dropped on the next tick); call detach to let the task run to completion independently of the handle.

Traits§

EventContextAsyncExt
Spawn async work on the main-thread executor from inside an event handler.
TeksiloAppBuilderAsyncStdExt
Adds install_async_async_std to the app builder.

Functions§

spawn_blocking
Run f on a dedicated OS thread and resolve to its return value. Await the returned future inside a spawn_local body to keep heavy/blocking work off the UI thread: