← All projects

darvaza.org/x/sync

Synchronisation primitive interfaces with panic-safe cleanup.

Defines Mutex, RWMutex, and their context-aware variants as interfaces, with panic-safe wrappers (SafeLock, SafeUnlock, …) that recover panics via core.Catch() and aggregate errors. Multi-mutex operations acquire locks in order and reverse-unlock on failure.

Higher-level primitives: SpinLock (atomic CAS), channel-based Semaphore (concurrent readers, exclusive writers), Barrier and Count condition variables, and workgroup.Group — a context-aware goroutine manager with cancellation propagation and panic recovery.