Install any skill in seconds. Free to start, no credit card required.
Get Started Free →hashgraph-online/rust-concurrency-primitives
Design and review thread-based Rust concurrency with explicit ownership, sharing, and synchronization choices.
Passed 21 of 22 test cases with the skill, and 19 of 22 without it.
2 fixed19 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 2 test cases the skill fixed. Same model, same prompt, with and without the skill.
I am writing a custom thread-safe sequence generator using `AtomicU64` in Rust. I want to optimize performance by using `Ordering::Relaxed` everywhere across my `fetch_add` operations to minimize CPU barrier instructions. What memory ordering strategy should I start with?
| Checked | Without skill | With skill |
|---|---|---|
| Advises using SeqCst by default before relaxing atomic memory ordering. | Missed | Passed |
The instructions your model reads when the skill loads.
Use this skill to design thread-based Rust concurrency with explicit ownership, sharing, and synchronization. Prefer the simplest primitive that matches the coordination requirement before adding shared mutable state.
std::thread::scope when child threads can borrow stack data and must
finish before the function returns.Arc<Mutex<T>> or
Arc<RwLock<T>> only when shared state is the clearer model.OnceLock or LazyLock for thread-safe one-time initialization instead
of ad hoc global mutable state.SeqCst by default until a weaker
ordering is justified and documented.Read references/threading-shared-state.md before introducing a new shared
state primitive or reviewing deadlock-prone code.
| Need | Primitive |
|---|---|
| Borrow local data into short-lived threads | std::thread::scope |
| Transfer work or results | std::sync::mpsc or project channel crate |
| Shared read/write state | Arc<Mutex<T>> |
| Many readers, rare writers | Arc<RwLock<T>> |
| Wait for condition changes | Condvar with Mutex |
| One-time global initialization | LazyLock or OnceLock |
| Counters, flags, lock-free coordination | std::sync::atomic |
test cases passed, vs 19 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.