Apache Asyncband™ (Incubating): Composable, runtime-agnostic concurrency building blocks for async Rust.

Clone this repo:
  1. 16c00d4 fix(pool): saturate ObjectStatus::recycle_count on increment (#495) by Biao Ma · 8 hours ago main
  2. a3c42f5 chore: align deslopify guidance with code roles (#502) by tison · 18 hours ago
  3. 3aac6ef refactor: simplify OnceCell insertion and owned waits in Latch and AutoResetEvent (#498) by Nanami · 2 days ago
  4. c0edf84 test: verify waker contract boundaries in Latch and Barrier (#499) by Nanami · 2 days ago
  5. b6b8adf chore: align release skill website update with asyncband-site workflow (#490) by tison · 5 days ago

Apache Asyncband™ (Incubating)

Crates.io Documentation MSRV 1.86 Apache 2.0 licensed Build Status

[!IMPORTANT]

Apache Asyncband (Incubating) is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.

Please read the DISCLAIMER and a full explanation of “incubating”.

Asyncband was formerly published as MEA. The mea crate is deprecated and receives no further development. See the migration guide for migration instructions and details about the rename.

Overview

Apache Asyncband™ is a focused collection of composable, runtime-agnostic concurrency building blocks for async Rust. It provides synchronization, initialization, task coordination, channels, resource reuse, and workload control without choosing an executor for the application.

Asyncband‘s async APIs build on standard Rust Future and Waker contracts without binding to a concrete executor, I/O reactor, or OS timer driver, and compose directly with native async/await control flow rather than callback or combinator chains. Applications can poll its futures on Tokio, async-std, smol, or a custom executor; see DESIGN.md for the project’s architectural guidelines.

Getting started

The crate enables no APIs by default. Enable only the features your application uses:

cargo add asyncband --features mutex
use asyncband::mutex::Mutex;

async fn increment() {
    let counter = Mutex::new(0);
    *counter.lock().await += 1;
    assert_eq!(*counter.lock().await, 1);
}

Public paths stay direct—such as asyncband::mutex, asyncband::pool, and asyncband::once::OnceCell—while Cargo features keep unused implementations out of the build.

Examples

Runnable examples live in the examples workspace crate. They demonstrate how to choose and compose Asyncband primitives in complete programs.

Benchmarks

Use cargo x bench to run fixed workloads measured in milliseconds. See the benchmark guide for filtering, repeated comparisons, workload sizes, and timing boundaries.

API map

AreaAPIFeatureUse
Locks and conditionsMutexmutexProtect shared data with asynchronous mutual exclusion.
RwLockrwlockAllow multiple readers or one writer.
UpgradableRwLockrwlockAllow multiple readers or one writer, with one upgradable reader.
CondvarcondvarWait for notifications while releasing a mutex.
CoordinationSemaphoresemaphoreLimit concurrent work by acquiring permits.
BarrierbarrierSynchronize a fixed number of participants at a reusable rendezvous.
ManualResetEventeventSignal current and future waits until explicitly reset.
AutoResetEventeventRetain one signal and release one waiter per consumed signal.
LatchlatchWait until a fixed one-way countdown reaches zero.
PhaserphaserCoordinate repeated phases with a dynamic participant set.
WaitGroupwaitgroupDynamically register participants and wait until all have completed.
ShutdownshutdownRequest shutdown and wait until all completion guards are dropped.
Work coalescingOnceonceComplete one asynchronous initialization; cancelled or panicked attempts may be retried.
OnceCellonce-cellStore one value from an access-time initializer; failed, cancelled, or panicked attempts may be retried.
LazyCelllazy-cellInitialize one value with a stored function and resume the same in-flight future after caller cancellation.
OnceMaponce-mapCoalesce work per key and retain each successful value until explicitly removed.
GroupsingleflightCoalesce overlapping work per key without retaining completed values.
CommunicationCompletioncompletionPublish one shared result to any number of current and future observers.
oneshotoneshotSend one value from one sender to one receiver.
mpmcmpmcDistribute each value to exactly one of multiple competing receivers.
mpscmpscSend each value from multiple producers to one receiver with bounded backpressure or an unbounded queue.
spmcspmcDistribute work from one exclusive sender to multiple competing receivers, with bounded or unbounded storage.
broadcastbroadcastDeliver every value to active receivers with bounded backpressure or unbounded retention.
watchwatchPublish cloneable latest state from one or more senders; receivers independently coalesce intermediate updates.
Object reusepoolpoolReuse objects through bounded or unbounded pool variants.
Sync interopFutureExtblockingDrive one runtime-agnostic future from a blocking thread.

Synchronous interoperability

The optional blocking module is a boundary adapter for synchronous callers. It parks the calling thread while driving one future; it is not a general-purpose executor.

cargo add asyncband --features blocking,oneshot
use std::thread;

use asyncband::blocking::FutureExt as _;
use asyncband::oneshot;

let (sender, receiver) = oneshot::channel();
thread::spawn(move || {
    let result = 6 * 7;
    sender.send(result).unwrap();
});

assert_eq!(receiver.block_on(), Ok(42));

Async first, blocking by adaptation

Async and synchronous synchronization primitives have different optimization constraints. Once an async operation is exposed as a runtime-agnostic future, synchronous code can usually drive that future through a block_on adapter. Asyncband therefore designs its primitives for async use and provides blocking interoperability at the boundary instead of duplicating synchronous methods across every type.

A sync-first implementation can exploit OS- or platform-specific facilities that an async implementation cannot assume. Libraries focused on synchronous code can therefore make different and sometimes better tradeoffs. Asyncband leaves those optimizations to dedicated libraries rather than treating blocking adaptation as a second family of primitives.

Execution constraints

The blocking module is a lightweight, thread-parking single-future executor, not a general-purpose async runtime. wait_timeout drops the future on timeout. Futures that depend on a runtime-specific timer or I/O driver still need that runtime's driver to make progress, and blocking an executor thread can cause starvation or deadlocks. See the blocking module documentation for the full contract.

Thread safety

Asyncband types implement Send and Sync only when the protected, transferred, or managed value satisfies the necessary bounds. See each API's documentation for its exact contract.

Minimum Supported Rust Version (MSRV)

This crate is built against the latest stable release, and its minimum supported rustc version is 1.86.0.

The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Asyncband 1.0 requires Rust 1.20.0, then Asyncband 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Asyncband 1.y for y > 0 may require a newer minimum version of Rust.

Community and contributing

Questions, bug reports, and feature requests are welcome through GitHub issues and GitHub discussions. Visit the Apache Asyncband website for engineering blog posts and verified downloads, and the community guide for public mailing lists, governance, voting rules, and other ways to participate.

See CONTRIBUTING.md to build, test, and contribute to Asyncband. All project participation is governed by the Apache Software Foundation Code of Conduct.

Security

Report suspected vulnerabilities privately to security@apache.org, with “Asyncband” in the subject. Follow the ASF vulnerability reporting process and see SECURITY-THREAT-MODEL.md for scope details.

Branding

The first and most prominent mentions must use the full form: Apache Asyncband™ (and Apache Asyncband™ (Incubating) while undergoing incubation) for any individual usage (webpage, handout, slides, etc.). Depending on the context and writing style, you should use the full form of the name sufficiently often to ensure that readers clearly understand the association of both the Asyncband project and the Asyncband software product to the ASF as the parent organization.

Source code is licensed under the Apache License, Version 2.0, which does not grant rights to use the project names, logos, or icons; third-party distributions or derivative works must comply with the ASF Trademark Policy and use distinct branding.

For more details, see the Apache Product Name Usage Guide.

License and Trademarks

This project is licensed under Apache License, Version 2.0; the license file also records incorporated third-party works and their terms.

Apache Asyncband, Asyncband, Apache, the Apache logo, and the Apache Asyncband project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. All other marks mentioned may be trademarks or registered trademarks of their respective owners.