Expand description
Asynchronous synchronization primitives
Synchronization primitives are tools for implementing synchronization between tasks: to control which tasks can run at any given time, and in what order, and to coordinate tasks’ access to shared resources. Typically, this synchronization involves some form of waiting. In asynchronous systems, synchronization primitives allow tasks to wait by yielding to the runtime scheduler, so that other tasks may run while they are waiting. This module provides asynchronous implementations of common synchronization primitives.
The following synchronization primitives are provided:
Mutex
: a fairly queued, asynchronous mutual exclusion lock, for protecting shared dataRwLock
: a fairly queued, asynchronous readers-writer lock, which allows concurrent read access to shared data while ensuring write access is exclusiveSemaphore
: an asynchronous counting semaphore, for limiting the number of tasks which may run concurrentlyWaitCell
, a cell that stores a single waiting task’sWaker
, so that the task can be woken by another task,WaitQueue
, a queue of waiting tasks, which are woken in first-in, first-out orderWaitMap
, a set of waiting tasks associated with keys, in which a task can be woken by its key
Note: maitake
’s synchronization primitives do not require the
maitake
runtime, and can be used with any async executor. Therefore,
they are provided by a separate maitake-sync
crate, which can be
used without depending on the rest of the maitake
runtime. This module
re-exports these APIs from maitake-sync
.
Modules§
- An asynchronous mutual exclusion lock.
- An asynchronous readers-writer lock.
- An asynchronous counting semaphore.
- Synchronous spinning-based synchronization primitives.
- Reusable utilities for synchronization primitives.
- An atomically registered
Waker
, for waking a single task. - A map of
Waker
s associated with keys, so that a task can be woken by key. - A queue of waiting tasks that can be woken in first-in, first-out order (or all at once).
Structs§
- An asynchronous mutual exclusion lock for protecting shared data.
- An asynchronous readers-writer lock.
- An asynchronous counting semaphore.
- An atomically registered
Waker
. - A map of
Waker
s associated with keys, allowing tasks to be woken by their key. - A queue of waiting tasks which can be woken in first-in, first-out order, or all at once.