lib/sync
import "github.com/eugenioenko/goalchemy/lib/sync"Package sync provides Goalchemy’s synchronization primitives.
| Function | c | csharp | go | java | python | rust | swift | typescript |
|---|---|---|---|---|---|---|---|---|
Mutex.Lock |
yes | yes | yes | yes | yes | yes | yes | yes |
Mutex.Unlock |
yes | yes | yes | yes | yes | yes | yes | yes |
WaitGroup.Add |
yes | yes | yes | yes | yes | yes | yes | yes |
WaitGroup.Done |
yes | yes | yes | yes | yes | yes | yes | yes |
WaitGroup.Wait |
yes | yes | yes | yes | yes | yes | yes | yes |
Mutex.Lock
Section titled “Mutex.Lock”func (m *Mutex) Lock()Acquire, or wait in FIFO order.
- Gate:
cooperative(may suspend the calling task) - Determinism: controlled
- Contract:
std.sync.mutex.lock1.0.0
Mutex.Unlock
Section titled “Mutex.Unlock”func (m *Mutex) Unlock()Hand the lock to the first waiter or release it.
- Gate:
sequential(never suspends) - Determinism: deterministic
- Errors: Unlocking an unlocked mutex is a fatal error (sync: unlock of unlocked mutex), not a recoverable panic.
- Contract:
std.sync.mutex.unlock1.0.0
WaitGroup.Add
Section titled “WaitGroup.Add”func (wg *WaitGroup) Add(delta int)Adjust the counter; at zero, release every waiter.
- Gate:
sequential(never suspends) - Determinism: deterministic
- Contract:
std.sync.waitgroup.add1.0.0
WaitGroup.Done
Section titled “WaitGroup.Done”func (wg *WaitGroup) Done()Add(-1).
- Gate:
sequential(never suspends) - Determinism: deterministic
- Contract:
std.sync.waitgroup.done1.0.0
WaitGroup.Wait
Section titled “WaitGroup.Wait”func (wg *WaitGroup) Wait()Return at zero, otherwise wait.
- Gate:
cooperative(may suspend the calling task) - Determinism: controlled
- Contract:
std.sync.waitgroup.wait1.0.0