← ClaudeAtlas

rust-async-internalslisted

Use when you author or review async Rust that can be polled inside tokio::select!, tokio::time::timeout, JoinSet, or FuturesUnordered; when you bridge a foreign thread into a runtime with block_on; when you configure a tokio runtime for a constrained target; when you design CancellationToken parent/child shutdown trees; when you choose between spawn_blocking, block_in_place, and std::thread::spawn; when you poll a future by hand from a synchronous event loop; or when you audit for std::sync::Mutex-across-await deadlocks, broadcast Lagged data loss, !Send futures, and cancel-safety bugs. Triggers on "select", "join", "spawn", "cancellation", "tokio runtime", "block_on", "async fn in traits", "task stall", "shutdown hang", or "async hang".
po4yka/rust-skills · ★ 2 · AI & Automation · score 76
Install: claude install-skill po4yka/rust-skills
# Rust Async Internals ## When to use this skill Use this skill when you do one of these things: - You author or review an `async fn` that can be polled inside `tokio::select!`, `tokio::time::timeout`, `JoinSet`, or `FuturesUnordered`. - You bridge a foreign thread (JNI, a C callback, a platform service thread) into a tokio runtime with `block_on`. - You configure a runtime for a constrained target, or you decide between `current_thread` and `multi_thread`. - You design shutdown with `CancellationToken`. - You choose between `spawn_blocking`, `block_in_place`, and `std::thread::spawn`. - You poll a future by hand from a synchronous loop. - You diagnose a stall, a shutdown hang, a latency spike, or a silent message loss. ## Decision table Read this table first. It answers most async design questions in one line. | You must | Use | Do not use | |---|---|---| | Run N futures and keep only the first result | `tokio::select!` | `join!` | | Run N futures to completion | `tokio::join!` or `try_join!` | `select!` | | Own a dynamic set of spawned tasks | `JoinSet` | a bare `Vec<JoinHandle>` | | Bound the concurrency of a work stream | `stream::iter(..).buffer_unordered(K)` | `spawn` in an unbounded loop | | Shut down a task tree | `CancellationToken` + `child_token()` | `Notify` | | Cancel on any early return or panic | `token.drop_guard()` | manual cleanup at each `?` | | Race work against shutdown and keep the value | `token.run_until_cancelled(fut)` | a hand-written