On this page
rust/std/sync
Prev: smart_pointers | Up: std | Next: io_and_fs
Rel: rust/builtins, Ownership & Internals
Ref: Rust std — sync
Tags: #public #prog #rust #stdlib #sync #index
Import
use std::sync::{Arc, Mutex, RwLock, OnceLock, mpsc};
Overview
Thread-safe synchronization, channels, atomics, and lazy one-time initialization.
Core (#tier/core)
- `Mutex` — Mutual-exclusion lock that owns the protected data
T— impossible to accessTwithout locking. - `mpsc` — Multi-producer, single-consumer FIFO channel for message passing between threads.
Standard (#tier/standard)
- `RwLock` — Allows many concurrent readers (
.read()) OR one exclusive writer (.write()). - `OnceLock` — Thread-safe one-time initialization cell for global singletons without
unsafeor external crates.
Specialized (#tier/specialized)
- `AtomicUsize` — Lock-free atomic integer supporting
load,store,fetch_add, andcompare_exchange.
Linked from
Related notes
- tuts/rust/std Linked here; links to this page; shared tags: #index, #prog, #rust, #stdlib
- tuts/rust/std/io_and_fs Linked here; links to this page; shared tags: #index, #prog, #rust, #stdlib
- tuts/rust/std/smart_pointers Linked here; links to this page; shared tags: #index, #prog, #rust, #stdlib
- tuts/rust/std/sync/AtomicUsize Linked here; links to this page; shared tags: #prog, #rust, #stdlib, #sync
- tuts/rust/std/sync/mpsc Linked here; links to this page; shared tags: #prog, #rust, #stdlib, #sync
- tuts/rust/std/sync/Mutex Linked here; links to this page; shared tags: #prog, #rust, #stdlib, #sync
- tuts/rust/std/sync/OnceLock Linked here; links to this page; shared tags: #prog, #rust, #stdlib, #sync
- tuts/rust/std/sync/RwLock Linked here; links to this page; shared tags: #prog, #rust, #stdlib, #sync
- tuts/rust/builtins Linked here; shared tags: #index, #prog, #rust
- tuts/rust/ownership_and_internals Linked here; shared tags: #index, #prog, #rust