← ClaudeAtlas

gcd-operationslisted

Use for iOS/macOS concurrency problems involving dispatch queues, locks, or thread safety. Triggers on: deadlocks (sync on main, nested sync, ABBA lock ordering), thread explosion from too many DispatchQueue.global() calls, data races flagged by Thread Sanitizer (TSan), DispatchGroup enter/leave imbalance, DispatchSource timer leaks, lock selection (NSLock vs OSAllocatedUnfairLock vs os_unfair_lock), reader-writer barriers, AsyncOperation subclasses, dispatchPrecondition usage, and OperationQueue throttling. Also use when migrating GCD patterns to Swift Concurrency actors. Apply whenever someone asks about thread-safe properties, concurrent access to shared state, or sees TSan warnings in Apple platform code — even if they don't say 'GCD' or 'concurrency.'
christim427-rgb/ios-agent-skills · ★ 1 · AI & Automation · score 77
Install: claude install-skill christim427-rgb/ios-agent-skills
# GCD & OperationQueue Concurrency Enterprise-grade concurrency skill for Grand Central Dispatch and OperationQueue. Opinionated: prescribes serial queues by default, target queue hierarchies, labeled queues, `NSLock`/`OSAllocatedUnfairLock` for synchronization, barrier-based reader-writer on custom concurrent queues, and OperationQueue for dependency graphs. Apple has **not deprecated any core GCD APIs** — GCD remains appropriate for parallelism, system I/O, and performance-critical paths. This skill covers correct usage, deadly bug prevention, and coexistence with Swift Concurrency. ## Concurrency Layers ```text Application Layer -> OperationQueue for dependency graphs, cancellation, throttling. Dispatch Layer -> Serial queues for state protection, concurrent+barrier for R/W. Synchronization -> NSLock / OSAllocatedUnfairLock for short critical sections. System I/O -> DispatchSource (timers, file monitoring), DispatchIO (non-blocking file I/O). Thread Pool -> GCD manages threads. App targets 3-4 well-defined queue subsystems. ``` ## Quick Decision Trees ### "Which queue type should I use?" ``` Do you need mutual exclusion (protecting shared state)? +-- YES -> Serial queue (default). Simplest, safest. +-- NO -> Is this independent parallel work (image processing, batch transforms)? +-- YES -> Concurrent queue (custom) with barrier for any writes. +-- NO -> Do you need dependency graphs, cancellation, or throttling? +--