m07-concurrency

Guide safe Send/Sync usage and synchronization primitives in Rust concurrency design.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/cecon123/tg-remote-bot --skill m07-concurrency-cecon123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m07-concurrency
Source: https://github.com/cecon123/tg-remote-bot/tree/main/.agents/skills/m07-concurrency
Command: npx skills add https://github.com/cecon123/tg-remote-bot --skill m07-concurrency-cecon123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers reason about concurrency and async in Rust, guiding safe sharing, synchronization, and error avoidance.

Core Features & Use Cases

  • Guided Concurrency Design: Learn when to use threads vs async, and how to select synchronization primitives (Arc, Mutex, RwLock, channels) for safe data sharing.
  • Error Prevention & Debugging: Recognize and prevent common Send/Sync and deadlock patterns with actionable mental models and trace-down techniques.
  • Real-World Scenarios: Apply patterns to multi-threaded data processing, I/O-bound workloads, and task orchestration in Rust services.

Quick Start

Add a small example that uses Arc<Mutex<T>> for shared state and spawns a Tokio task to modify it.

Frequently Asked Questions about m07-concurrency

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

FAQPage Schema
How do I share state safely across async tasks in Rust?

To share state safely across async tasks in Rust, wrap your data in Arc<Mutex<T>> or Arc<RwLock<T>>. This allows multiple Tokio tasks to access and modify shared data concurrently without causing data races.

When should I use threads vs async for concurrency in Rust?

Use async for I/O-bound workloads and task orchestration, while threads suit CPU-bound multi-threaded data processing. Choosing the right Rust concurrency model prevents bottlenecks and ensures efficient resource utilization.

Why does my Rust code fail to compile with Send or Sync trait errors?

Send and Sync errors occur when types cross thread or task boundaries unsafely. Guided concurrency design helps trace down these violations and apply correct synchronization primitives to satisfy Rust's safety guarantees.

What's the best way to avoid deadlocks when using Mutex in Rust async?

Avoid deadlocks in Rust async by never holding Mutex guards across .await points. Use structured concurrency patterns and channels for task communication to prevent locks from blocking the async runtime.

How do I use Tokio channels for task orchestration in Rust services?

Use Tokio channels like mpsc or broadcast to orchestrate tasks in Rust services. Channels provide thread-safe message passing, decoupling producers and consumers for safe async data flow without shared state.

Can I use RwLock instead of Mutex for high-concurrency Rust services?

RwLock is suitable for high-concurrency Rust services with many readers and few writers. It allows multiple concurrent read locks, improving throughput compared to Mutex when write contention is low.