m07-concurrency

Guide safe Rust concurrency design using Send/Sync and async primitives.

Updated Jan 21, 2026
One-click install
npx skills add https://github.com/lywa1998/self-host-claude-marketplace --skill m07-concurrency-lywa1998
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m07-concurrency
Source: https://github.com/lywa1998/self-host-claude-marketplace/tree/main/plugins/rust-skills/skills/m07-concurrency
Command: npx skills add https://github.com/lywa1998/self-host-claude-marketplace --skill m07-concurrency-lywa1998

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers reason about Rust concurrency and async patterns, guiding safe use of Send/Sync, threads, and async runtimes to prevent data races and deadlocks.

Core Features & Use Cases

  • Understand when to use threads vs async, how to model shared state with Arc and Mutex, and how to avoid common pitfalls like holding locks across await.
  • Apply domain tracing to identify appropriate concurrency strategies for Web APIs, CLI tools, or data-processing pipelines.
  • Use concrete patterns like Arc<Mutex<T>>, channels, and spawn_local to structure safe, scalable concurrent code.

Quick Start

Create a small Rust program using Tokio to spawn multiple tasks that share state via Arc<Mutex<T>> and await their completion.

Frequently Asked Questions about m07-concurrency

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

FAQPage Schema
How do I share mutable state across async tasks in Rust without causing data races?

For safe Rust concurrency, use Arc<Mutex<T>> to share mutable state across threads and channels for message passing. Choose async for I/O-bound work and OS threads for CPU-bound tasks to optimize runtime performance.

Why does my Rust async code deadlock when holding a Mutex lock across an await point?

Rust concurrency design patterns enforce Send/Sync traits to guarantee thread safety. The compiler statically verifies that types safely transfer ownership across threads and allow shared references without data races.

What is the best way to structure a Rust concurrency design for a Web API?

Use spawn_local for Rust async tasks that do not implement Send, keeping them pinned to a single thread. This avoids forcing Send bounds when your data structures are strictly thread-local.

When should I use threads instead of async Tokio for Rust concurrency?

Rust concurrency design patterns enforce Send/Sync traits to guarantee thread safety. The compiler statically verifies that types safely transfer ownership across threads and allow shared references without data races.

How do I fix Rust Send and Sync trait errors when spawning async tasks?

For safe Rust concurrency, use Arc<Mutex<T>> to share mutable state across threads and channels for message passing. Choose async for I/O-bound work and OS threads for CPU-bound tasks to optimize runtime performance.

Can I use channels instead of Arc Mutex for thread-safe data sharing in Rust?

Yes, you can use channels instead of Arc<Mutex<T>> for thread-safe Rust concurrency. Channels apply message-passing patterns to eliminate shared mutable state, preventing deadlocks and simplifying task synchronization.