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

Download history 571/week @ 2026-02-24 498/week @ 2026-03-03 567/week @ 2026-03-10 654/week @ 2026-03-17 513/week @ 2026-03-24 567/week @ 2026-03-31 535/week @ 2026-04-07 589/week @ 2026-04-14 548/week @ 2026-04-21 475/week @ 2026-04-28 519/week @ 2026-05-05 545/week @ 2026-05-12 564/week @ 2026-05-19 891/week @ 2026-05-26 659/week @ 2026-06-02 817/week @ 2026-06-09

3,019 downloads per month
Used in 36 crates (7 directly)

MIT/Apache

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/Receiver types
  • Single-threaded LocalSender/LocalReceiver variants
  • Sink and Stream trait 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