Skip to content

Commit 08f5f76

Browse files
committed
refactor(channels): prototype the 0.7 design
1 parent 263582e commit 08f5f76

36 files changed

Lines changed: 3905 additions & 3660 deletions

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased
66

7+
### Breaking changes
8+
9+
* Group all channel families under `mea::channel` and replace the previous root-level oneshot, mpsc, and broadcast implementations with a shared correctness-first design.
10+
* Use `is_disconnected` consistently for channel endpoint state queries.
11+
12+
### New features
13+
14+
* Add SPSC, MPSC, SPMC, and MPMC queues with rendezvous, bounded, and unbounded capacities.
15+
* Add explicit bounded-queue replacement strategies that return the displaced value.
16+
* Add overflow, backpressure, and unbounded broadcast retention policies.
17+
* Add a coalescing watch channel.
18+
* Add single-producer and multi-producer Disruptor-style multicast sequencers.
19+
* Add `sync`, `channel`, `coordination`, and `atomic` public module groups for the proposed 0.7 layout.
20+
721
### Bug fixes
822

923
* Prevent `OwnedMappedMutexGuard` from allowing invalid lifetime coercions. ([#121](https://github.com/fast/mea/pull/121))

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ MEA is a runtime-agnostic library providing essential synchronization primitives
2222

2323
## Features
2424

25+
### Synchronization
26+
2527
* [**Barrier**](https://docs.rs/mea/*/mea/barrier/struct.Barrier.html): A synchronization primitive that enables tasks to wait until all participants arrive.
2628
* [**Condvar**](https://docs.rs/mea/*/mea/condvar/struct.Condvar.html): A condition variable that allows tasks to wait for a notification.
2729
* [**Latch**](https://docs.rs/mea/*/mea/latch/struct.Latch.html): A synchronization primitive that allows one or more tasks to wait until a set of operations completes.
@@ -32,12 +34,23 @@ MEA is a runtime-agnostic library providing essential synchronization primitives
3234
* [**RwLock**](https://docs.rs/mea/*/mea/rwlock/struct.RwLock.html): A reader-writer lock that allows multiple readers or a single writer at a time.
3335
* [**Semaphore**](https://docs.rs/mea/*/mea/semaphore/struct.Semaphore.html): A synchronization primitive that controls access to a shared resource.
3436
* [**WaitGroup**](https://docs.rs/mea/*/mea/waitgroup/struct.WaitGroup.html): A synchronization primitive that allows waiting for multiple tasks to complete.
37+
38+
### Channels
39+
40+
All channel families are grouped under [**mea::channel**](https://docs.rs/mea/*/mea/channel/):
41+
42+
* **oneshot** transfers one value once.
43+
* **spsc**, **mpsc**, **spmc**, and **mpmc** provide rendezvous, bounded, and unbounded competing-consumer queues.
44+
* **broadcast** provides bounded overflow, bounded backpressure, and unbounded multicast retention.
45+
* **watch** distributes the latest state while coalescing intermediate versions.
46+
* **disruptor** provides single-producer and multi-producer bounded multicast sequencers.
47+
48+
See the [channel design for 0.7](docs/channel-design.md) for the topology matrix, overload policies, cancellation rules, Disruptor invariants, and proposed Cargo feature groups.
49+
50+
### Coordination and atomic utilities
51+
3552
* [**admission::FairShare**](https://docs.rs/mea/*/mea/admission/struct.FairShare.html): A work-conserving admission policy that fairly shares bounded concurrency across keys.
3653
* [**atomicbox**](https://docs.rs/mea/*/mea/atomicbox/): A safe, owning version of AtomicPtr for heap-allocated data.
37-
* [**broadcast**](https://docs.rs/mea/*/mea/broadcast/): A multi-producer, multi-consumer broadcast channel.
38-
* [**mpsc::bounded**](https://docs.rs/mea/*/mea/mpsc/fn.bounded.html): A multi-producer, single-consumer bounded queue for sending values between asynchronous tasks.
39-
* [**mpsc::unbounded**](https://docs.rs/mea/*/mea/mpsc/fn.unbounded.html): A multi-producer, single-consumer unbounded queue for sending values between asynchronous tasks.
40-
* [**oneshot::channel**](https://docs.rs/mea/*/mea/oneshot/): A one-shot channel for sending a single value between tasks.
4154
* [**shutdown**](https://docs.rs/mea/*/mea/shutdown/): A composite synchronization primitive for managing shutdown signals.
4255
* [**singleflight::Group**](https://docs.rs/mea/*/mea/singleflight/): A duplicate function call suppression mechanism.
4356

@@ -55,7 +68,7 @@ All synchronization primitives in this library are runtime-agnostic, meaning the
5568

5669
## Thread Safety
5770

58-
All types in this library implement `Send` and `Sync`, making them safe to share across thread boundaries. This is essential for concurrent programming where data needs to be accessed from multiple threads.
71+
Types implement `Send` when their contained values can cross thread boundaries. A channel endpoint is `Sync` and cloneable when that endpoint supports multiple producers or multiple consumers; a single-side endpoint deliberately requires exclusive access.
5972

6073
## Minimum Supported Rust Version (MSRV)
6174

@@ -82,8 +95,7 @@ This crate collects runtime-agnostic synchronization primitives from spare parts
8295
* **Semaphore** is derived from `tokio::sync::Semaphore`, without `close` method since it is quite tricky to use. And thus, this semaphore doesn't have the limitation of max permits. Besides, new methods like `forget_exact` are added to fit the specific use case.
8396
* **WaitGroup** is inspired by [`waitgroup-rs`](https://github.com/laizy/waitgroup-rs), providing different API flavor with a different implementation based on the internal `CountdownState` primitive.
8497
* **atomicbox** is forked from [`atomicbox`](https://github.com/jorendorff/atomicbox/) at commit 07756444.
85-
* **broadcast::overflow::channel** is derived from `tokio::sync::broadcast::channel`, with a different implementation based on the internal `WaitSet` primitive.
86-
* **oneshot::channel** is derived from [`oneshot`](https://github.com/faern/oneshot), with significant simplifications since we need not support synchronized receiving functions.
98+
* **channel** is a correctness-first implementation of one-shot, competing-consumer, multicast, coalescing, and Disruptor-style sequenced channels using runtime-agnostic task parking.
8799

88100
Other parts are written from scratch.
89101

0 commit comments

Comments
 (0)