actionbook avatar

M07 Concurrency

Thread-safety and async guidance for Send/Sync errors, locking choices, and deadlock or race debugging.

skills.sh installs
3.8K
GitHub stars
1.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the choice between CPU-bound threads and I/O-bound async, plus the sharing model for each workload
  • Includes Send and Sync marker guidance, a decision flowchart for Arc, Mutex, RwLock, and channels, and common E0277 and MutexGuard-across-await fixes
  • Enforces tight lock scoping and consistent lock ordering to avoid deadlocks and blocked executors
  • Designed for Rust projects with web handlers, CLI tools, or trading systems that need thread-safe shared state

Install

$ npx -y skills add actionbook/rust-skills --skill m07-concurrency -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Concurrency

Layer 1: Language Mechanics

Core Question

Is this CPU-bound or I/O-bound, and what's the sharing model?

Before choosing concurrency primitives:

  • What's the workload type?
  • What data needs to be shared?
  • What's the thread safety requirement?

Error → Design Question

ErrorDon't Just SayAsk Instead
E0277 Send"Add Send bound"Should this type cross threads?
E0277 Sync"Wrap in Mutex"Is shared access really needed?
Future not Send"Use spawn_local"Is async the right choice?
Deadlock"Reorder locks"Is the locking design correct?

Thinking Prompt

Before adding concurrency:

  1. What's the workload?

    • CPU-bound → threads (std::thread, rayon)
    • I/O-bound → async (tokio, async-std)
    • Mixed → hybrid approach
  2. What's the sharing model?

    • No sharing → message passing (channels)
    • Immutable sharing → Arc
    • Mutable sharing → Arc<Mutex> or Arc<RwLock>
  3. What are the Send/Sync requirements?

    • Cross-thread ownership → Send
    • Cross-thread references → Sync
    • Single-thread async → spawn_local

Details

Repository
github.com/actionbook/rust-skills
Category
Rust
First seen
May 16, 2026

More from actionbook/rust-skills

All 38

Similar to M07 Concurrency

More Rust