Module sync

Module sync 

Available on crate feature sync only.
Expand description

Synchronization primitives.

This module re-exports synchronization primitives from the standard library and from tokio.

This module renames tokio::sync::Mutex and tokio::sync::RwLock to AsyncMutex and AsyncRwLock respectively to avoid confusion with the standard library’s Mutex and RwLock types. Async and sync mutexes and rwlocks are not interchangeable. As a rule of thumb, if a lock is never held across an .await point, it’s likely more efficient to use a sync lock. Async locks have more overhead.

Modules§

atomic
Atomic types
broadcast
A multi-producer, multi-consumer broadcast queue. Each sent value is seen by all consumers.
mpsc
A multi-producer, single-consumer queue for sending values between asynchronous tasks.
oneshot
A one-shot channel is used for sending a single message between asynchronous tasks. The channel function is used to create a Sender and Receiver handle pair that form the channel.
watch
A multi-producer, multi-consumer channel that only retains the last sent value.

Structs§

Arc
A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
AsyncMutex
An asynchronous Mutex-like type.
AsyncOnceLock
A thread-safe cell that can be written to only once.
AsyncRwLock
An asynchronous reader-writer lock.
Barrierstd
A barrier enables multiple threads to synchronize the beginning of some computation.
Condvarstd
A Condition Variable
LazyLockstd
A value which is initialized on the first access.
Mutexstd
A mutual exclusion primitive useful for protecting shared data
MutexGuardstd
An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
Oncestd
A low-level synchronization primitive for one-time global execution.
OnceLockstd
A synchronization primitive which can nominally be written to only once.
RwLockstd
A reader-writer lock
RwLockReadGuardstd
RAII structure used to release the shared read access of a lock when dropped.
RwLockWriteGuardstd
RAII structure used to release the exclusive write access of a lock when dropped.
Weak
Weak is a version of Arc that holds a non-owning reference to the managed allocation.

Enums§

AsyncOnceLockSetError
Errors that can be returned from OnceCell::set.