rust-impl-async-tokio
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
rust-impl-async-tokio
The tokio runtime implementation skill: how to start a tokio runtime, spawn and join async tasks, race futures with select!, apply timeouts, cancel work safely, and use JoinSet for structured concurrency. Targets tokio 1.x on Rust 1.85+, edition 2024.
Cross-references: [[rust-core-async-runtime]] (Future trait, Waker model, why a runtime is needed), [[rust-syntax-async-await]] (async fn, .await, Send/Sync bounds across .await), [[rust-impl-channels]] (tokio::sync::mpsc, oneshot, broadcast, watch), [[rust-errors-async]] (JoinError, Elapsed, propagating panics across task boundaries).
When to use this skill
- User adds
tokiotoCargo.tomland asks which features (rt,rt-multi-thread,macros,time,sync,full). - User annotates
mainwith#[tokio::main]or hand-builds aRuntime. - User calls
tokio::spawn, getsJoinHandle<T>, asks how to wait for it or abort it. - User has CPU-bound or blocking sync work inside async code and asks where to run it.
- User wants to race two futures or apply a timeout.
- User wants to spawn a group of related tasks and cancel them together (structured concurrency).
- User sees
panicked at 'there is no reactor running'orcannot block the current thread from within a runtime.
For the Future trait, pinning, and runtime architecture see [[rust-core-async-runtime]]. For async fn / .await syntax and Send-across-await see [[rust-syntax-async-await]]. For channels see [[rust-impl-channels]]. For errors see [[rust-errors-async]].