#channel #mpmc #mpsc #spsc #spmc #mpmc-queue

no-std concurrent-queue

Concurrent multi-producer multi-consumer queue

14 stable releases

new 2.5.0 Apr 26, 2024
2.4.0 Dec 2, 2023
2.3.0 Sep 25, 2023
2.2.0 Apr 7, 2023
0.0.1 May 17, 2020

#43 in Concurrency

Download history 525744/week @ 2024-01-05 547290/week @ 2024-01-12 637179/week @ 2024-01-19 722275/week @ 2024-01-26 610343/week @ 2024-02-02 579727/week @ 2024-02-09 582139/week @ 2024-02-16 616411/week @ 2024-02-23 641870/week @ 2024-03-01 624152/week @ 2024-03-08 640858/week @ 2024-03-15 650798/week @ 2024-03-22 664974/week @ 2024-03-29 691892/week @ 2024-04-05 688487/week @ 2024-04-12 579495/week @ 2024-04-19

2,742,761 downloads per month
Used in 6,751 crates (43 directly)

Apache-2.0 OR MIT

64KB
1K SLoC

concurrent-queue

Build License Cargo Documentation

A concurrent multi-producer multi-consumer queue.

There are two kinds of queues:

  1. Bounded queue with limited capacity.
  2. Unbounded queue with unlimited capacity.

Queues also have the capability to get closed at any point. When closed, no more items can be pushed into the queue, although the remaining items can still be popped.

These features make it easy to build channels similar to std::sync::mpsc on top of this crate.

Examples

use concurrent_queue::ConcurrentQueue;

let q = ConcurrentQueue::unbounded();
q.push(1).unwrap();
q.push(2).unwrap();

assert_eq!(q.pop(), Ok(1));
assert_eq!(q.pop(), Ok(2));

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–26MB
~357K SLoC