go_lib/sync/mod.rs
1// SPDX-License-Identifier: Apache-2.0
2//! Synchronization primitives.
3//!
4//! [`Mutex`] and [`RwLock`] are re-exports of `std::sync`'s implementations:
5//! the uncontended path is just an atomic CAS, and the contended path is
6//! made scheduler-safe by wrapping `.lock()` with the M's syscall-handoff
7//! shim (see [`crate::runtime::syscall`]). Porting Go's `sync.Mutex` plus
8//! `runtime.sema` would add hundreds of lines for no measurable win.
9//!
10//! [`WaitGroup`] and [`Cond`] *are* ported because they benefit from
11//! goroutine-level parking: waiters yield to the scheduler rather than
12//! blocking an OS thread.
13
14pub use std::sync::{Mutex, RwLock};
15
16mod cond;
17pub use cond::Cond;
18
19mod waitgroup;
20pub use waitgroup::WaitGroup;