zig-concurrency
Zig 并发编程技能。涉及 std.Thread 的线程创建、同步原语(Mutex、RwLock、Condition、Semaphore、WaitGroup)、线程池和原子操作。在需要多线程或并行计算时调用。
Skill by Yabuku-xD
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/yabuku-xd-zig-concurrency
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/zig-concurrency
What's inside
- Skill name
zig-concurrency- Description
- Zig 并发编程技能。涉及 std.Thread 的线程创建、同步原语(Mutex、RwLock、Condition、Semaphore、WaitGroup)、线程池和原子操作。在需要多线程或并行计算时调用。
- License
- MIT
- Instructions
- 271 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Zig 并发编程
> 基于 std.Thread 和 std.atomic 的并发原语(Zig 0.16.0)。
## Capability Boundaries
### ✅ 强项
1. 线程创建与管理(spawn、join、detach)
2. 同步原语(Mutex、RwLock、Condition、Semaphore、ResetEvent、WaitGroup)
3. 线程池(Thread.Pool)用于并行任务
4. 原子操作(std.atomic.Value)
5. 常见并发模式(生产者-消费者、工作队列)
### ⚠️ 前置要求
1. 确认 Zig 版本(`zig version`)
2. 理解基本并发概念(竞态条件、死锁)
### ❌ 不适用范围
1. 异步 I/O → 使用 `zig-http` 或 `zig-0.16` 的 std.Io
2. 非并发场景 → 使用 `zig-0.16` 技能
## 何时使用
- "多线程处理数据"
- "并行执行多个任务"
- "线程安全的共享状态"
## Data Privacy
本技能不收集、存储或传输任何用户数据。
## Workflow
步骤 1. **识别并发需求** — CPU 密集 / I/O 等待 / 并行计算?
步骤 2. **选择原语** — 线程 / 线程池 / 原子操作?
步骤 3. **实现同步** — Mutex / RwLock / WaitGroup
步骤 4. **测试正确性** — 竞态条件、死锁检查
## 模块总览
```zig
std.Thread // 线程创建与管理
std.Thread.Mutex // 互斥锁
std.Thread.Mutex.Recursive // 可重入互斥锁
std.Thread.RwLock // 读写锁
std.Thread.Condition // 条件变量
std.Thread.Semaphore // 计数信号量
std.Thread.ResetEvent // 布尔事件标志(阻塞式)
std.Thread.WaitGroup // 等待多任务完成
std.Thread.Pool // 线程池
std.Thread.Futex // 底层 futex(高级)
std.atomic.Value(T) // 原子类型包装
```
## 线程创建
### 基本线程
```zig
fn worker(id: usize) void {
std.debug.print("Worker {d}\n", .{id});
}
const thread = try std.Thread.spawn(.{}, worker, .{42});
thread.join(); // 等待完成
```
### 带分配器配置
```zig
const thread = try std.Thread.spawn(.{ .allocator = allocator }, worker, .{42});
defer thread.join();
```
### 分离线程(不 join)
```zig
const thread = try std.Thread.spawn(.{}, worker, .{1});
thread.detach(); // 线程自动清理
```
## 同步原语
### Mutex(互斥锁)
```zig
var mutex: std.Thread.Mutex = .{};
var shared: i32 = 0;
fn increment() void {
mutex.lock();
defer mutex.unlock();
shared += 1;
}
```
### RwLock(读写锁)
```zig
var rwlock: std.Thread.RwLock = .{};
var data: i32 = 0;
fn reader() void {
rwlock.lockShared();
defer rwlock.unlockShared();
_ = data; // 可并发读
}
fn writer() void {
rwlock.lock();
defer rwlock.unlock();
data += 1; // 独占写
}
```
### Condition(条件变量)
```zig
var mutex: std.Thread.Mutex = .{};
var cond: std.Thread.Condition = .{};
var ready: bool = false;
fn waiter() void {
mutex.lock();
defer mutex.unlock();From Yabuku-xD/omfx, MIT.
More from Yabuku-xD/omfx
- 0.529score
zig-memory-management
Yabuku-xD
Memory management in Zig including allocators, pointers, slices, alignment, and ownership patterns.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-tiger-style
Yabuku-xD
TigerStyle Zig coding guidelines — distilled from TigerBeetle's production codebase.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-comptime
Yabuku-xD
Zig comptime skill for compile-time evaluation and metaprogramming.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-testing
Yabuku-xD
Zig testing skill for writing and running tests.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-code-review
Yabuku-xD
Review Zig project code for style, correctness, and logic.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-debugging
Yabuku-xD
Zig debugging skill.
SkillBFreshness: BClaude Code +9 - 0.518score
code-audit
Yabuku-xD
Conducts an exhaustive, multi-pass, line-by-line technical audit and verification of local files or directories.
SkillBFreshness: BClaude Code +9 - 0.518score
zig-project-structure
Yabuku-xD
Zig 项目结构全生命周期管理。创建项目骨架(exe/lib/多模块/带依赖)或检查已有项目的目录结构、文件命名、构建配置合规性,输出结构化报告。
SkillBFreshness: BClaude Code +9 - 0.518score
zig-testing
Yabuku-xD
Zig 测试与调试技能。涉及 std.testing 的断言、测试组织、内存泄漏检测、以及 std.debug 的日志、堆栈回溯。在需要编写测试、调试代码、诊断问题时调用。
SkillBFreshness: BClaude Code +9 - 0.518score
zig-build-system
Yabuku-xD
Zig 构建系统专项技能。涉及 build.zig 和 build.zig.zon 的编写、模块管理、依赖配置、交叉编译、C/C++ 集成、自定义构建步骤和测试配置。在需要配置或调试项目构建时调用。
SkillBFreshness: BClaude Code +9 - 0.516score
zig-build-system
Yabuku-xD
Zig build system skill for multi-file Zig projects.
SkillBFreshness: BClaude Code +9 - 0.515score
hello-omfx
Yabuku-xD
Example skill.
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 24, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Yabuku-xD/omfx
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Yabuku-xD
- 0.529score
zig-memory-management
Yabuku-xD
Memory management in Zig including allocators, pointers, slices, alignment, and ownership patterns.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-comptime
Yabuku-xD
Zig comptime skill for compile-time evaluation and metaprogramming.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-tiger-style
Yabuku-xD
TigerStyle Zig coding guidelines — distilled from TigerBeetle's production codebase.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-debugging
Yabuku-xD
Zig debugging skill.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-testing
Yabuku-xD
Zig testing skill for writing and running tests.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-code-review
Yabuku-xD
Review Zig project code for style, correctness, and logic.
SkillBFreshness: BClaude Code +9
Cite this page
zig-concurrency skill. Agent Mart. https://agentmart.dev/skills/yabuku-xd-zig-concurrency (last updated 2026-10-24)