9 releases
| 0.3.0 | May 30, 2026 |
|---|---|
| 0.2.6 | May 18, 2025 |
| 0.2.5 | Oct 18, 2024 |
| 0.2.3 | Oct 7, 2023 |
| 0.1.0 | Nov 25, 2022 |
#473 in Concurrency
3,019 downloads per month
Used in 36 crates
(7 directly)
130KB
3K
SLoC
mpsc
English | 简体中文
mpsc provides Multiple Producer Single Consumer channels built on top of queue-ext. Supports multiple backing queue implementations, each with different characteristics.
Features
- SegQueue channel — lock-free, crossbeam-based (default)
- VecDeque channel — standard Rust VecDeque backed
- Priority channel — items prioritized by key order
- IndexMap channel — deduplication by key (last write wins)
- Thread-safe
Sender/Receivertypes - Single-threaded
LocalSender/LocalReceivervariants SinkandStreamtrait implementations- Type-erased channel API
Cargo Feature Flags
| Feature | Description | Default |
|---|---|---|
segqueue |
Lock-free channel via crossbeam::SegQueue |
yes |
vecdeque |
Channel backed by std::collections::VecDeque |
no |
priority |
Priority channel via box-collections::PriorityQueue |
no |
indexmap |
Deduplicating channel via indexmap::IndexMap |
no |
Basic Usage
use mpsc::segqueue_channel;
use futures::executor::block_on;
let (mut tx, mut rx) = segqueue_channel(10);
block_on(tx.send(42)).unwrap();
assert_eq!(block_on(rx.recv()), Some(42));
More Examples
Tests
cargo test -p mpsc --features "segqueue,vecdeque,priority,indexmap"
37 tests covering all 4 channel types, LocalSender/Receiver, clone, and drop semantics.
License
Licensed under either of Apache License 2.0 or MIT license at your option.
Dependencies
~3–4MB
~72K SLoC