Skip to main content

Module sync

Module sync 

Source
Expand description

Synchronization primitives.

Mutex and RwLock are re-exports of std::sync’s implementations: the uncontended path is just an atomic CAS, and the contended path is made scheduler-safe by wrapping .lock() with the M’s syscall-handoff shim (see [crate::runtime::syscall]). Porting Go’s sync.Mutex plus runtime.sema would add hundreds of lines for no measurable win.

WaitGroup and Cond are ported because they benefit from goroutine-level parking: waiters yield to the scheduler rather than blocking an OS thread.

Structs§

Cond
A goroutine-aware condition variable.
Mutex
A mutual exclusion primitive useful for protecting shared data
RwLock
A reader-writer lock
WaitGroup
A synchronisation barrier: wait for a set of goroutines to complete.