rust-concurrency

Select threads, async, or rayon parallelism for Rust workloads.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/gregoryraymond/claude-agents-and-skills --skill rust-concurrency-gregoryraymond
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-concurrency
Source: https://github.com/gregoryraymond/claude-agents-and-skills/tree/main/skills/rust-concurrency
Command: npx skills add https://github.com/gregoryraymond/claude-agents-and-skills --skill rust-concurrency-gregoryraymond

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust concurrency is hard: it requires choosing between threads and asynchronous programming while ensuring Send/Sync correctness and avoiding deadlocks.

Core Features & Use Cases

  • Guidance on CPU-bound parallelism with std::thread and rayon.
  • Guidance on I/O-bound concurrency with tokio, including spawn_blocking and spawn_local.
  • Explanation of Send/Sync, Arc, Mutex, and channel patterns for safe shared state and communication.
  • Practical decision-making guidance for selecting the right model for a given workload.

Quick Start

Describe a simple Rust concurrency scenario where a thread computes a sum in parallel and returns the result.

Frequently Asked Questions about rust-concurrency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between threads and async for Rust concurrency?

Rust concurrency model selection depends on workload: use std::thread and rayon for CPU-bound parallelism, and tokio with async for I/O-bound tasks to ensure optimal resource utilization and performance.

When should I use spawn_blocking instead of spawn in tokio?

Use tokio's spawn_blocking for CPU-bound or blocking operations within an async context to prevent starving the async runtime. Standard spawn is for lightweight, non-blocking asynchronous tasks only.

How do I share state safely across threads in Rust?

Share state safely across Rust threads by combining Arc with Mutex or RwLock. Ensure types implement Send and Sync traits correctly to satisfy the compiler's thread safety guarantees during concurrent access.

What's the best way to avoid deadlocks in Rust async and threaded applications?

Avoid Rust deadlocks by carefully managing Mutex lock acquisition order and using channel patterns like mpsc or oneshot for thread communication instead of shared state where possible.

Can I use rayon for I/O-bound workloads in Rust?

Rayon is designed for CPU-bound data parallelism in Rust, not I/O-bound workloads. For I/O-bound concurrency, use tokio's async runtime with spawn or spawn_blocking to handle blocking operations efficiently.

What Rust channel types should I use for concurrent communication?

Rust offers mpsc for single-producer single-consumer streams, oneshot for sending a single value, and broadcast for multi-consumer messaging. Select the channel type matching your thread or async communication pattern.