Expand description
asyncband is a runtime-agnostic library providing essential synchronization primitives for
asynchronous Rust programming. The library offers a collection of well-tested, efficient
synchronization tools that work with any async runtime.
§Migrating from MEA
Asyncband continues the project formerly published as mea. The old crate is deprecated and no
compatibility crate or re-export is provided. Replace the mea dependency with asyncband and
update mea:: paths to asyncband::.
§Features
Barrier: A synchronization point where multiple tasks can wait until all participants arriveCondvar: A condition variable that allows tasks to wait for a notificationLatch: A single-use barrier that allows one or more tasks to wait until a signal is givenMutex: A mutual exclusion primitive for protecting shared dataOnce: A primitive that ensures a one-time asynchronous operation runs at most once, even when called concurrentlyOnceCell: A cell that can be written to at most once and provides safe concurrent accessOnceMap: A hash map that runs computation only once for each key and stores the result.RwLock: A reader-writer lock that allows multiple readers or a single writer at a timeSemaphore: A synchronization primitive that controls access to a shared resourceWaitGroup: A synchronization primitive that allows waiting for multiple tasks to completeadmission::FairShare: A work-conserving admission policy that fairly shares bounded concurrency across keysatomicbox: A safe, owning version ofAtomicPtrfor heap-allocated data.broadcast: A multi-producer, multi-consumer broadcast channel.mpsc::bounded: A multi-producer, single-consumer bounded queue for sending values between asynchronous tasks.mpsc::unbounded: A multi-producer, single-consumer unbounded queue for sending values between asynchronous tasks.oneshot::channel: A one-shot channel for sending a single value between tasks.shutdown: A composite synchronization primitive for managing shutdown signals.singleflight::Group: A duplicate function call suppression mechanism.
§Runtime Agnostic
All synchronization primitives in this library are runtime-agnostic, meaning they can be used with any async runtime like tokio, async-std, or others. This makes the library highly versatile and portable.
§Thread Safety
Asyncband primitives and guards implement Send and Sync only when the protected or
transferred value satisfies the necessary bounds. In particular, owned read guards that may move
destruction to another thread require the protected value to be Send as well as Sync. See
each type’s documentation for its exact bounds.
Modules§
- admission
- Admission control policies for bounded asynchronous work.
- atomicbox
AtomicBoxandAtomicOptionBoxare safe, owning versions of std’sAtomicPtr.- barrier
- A synchronization primitive that enables multiple tasks to wait for each other.
- broadcast
- A multi-producer multi-consumer broadcast channel.
- condvar
- A condition variable that allows tasks to wait for a notification.
- latch
- A countdown latch that allows one or more tasks to wait until a set of operations completes.
- mpsc
- A multi-producer, single-consumer queue for sending values between asynchronous tasks.
- mutex
- An async mutex for protecting shared data.
- once
- Asynchronous primitives for one-time async coordination.
- oneshot
- A one-shot channel is used for sending a single message between asynchronous tasks. The
channelfunction is used to create aSenderandReceiverpair that form the channel. - rwlock
- A reader-writer lock that allows multiple readers or a single writer at a time.
- semaphore
- An async counting semaphore for controlling access to a set of resources.
- shutdown
- A composite synchronization primitive for managing shutdown signals.
- singleflight
- Singleflight provides a duplicate function call suppression mechanism.
- waitgroup
- A synchronization primitive for waiting on multiple tasks to complete.