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

no-std concurrent-queue

Concurrent multi-producer multi-consumer queue

14 stable releases

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

#50 in Concurrency

Download history 793687/week @ 2024-07-21 815956/week @ 2024-07-28 839230/week @ 2024-08-04 895477/week @ 2024-08-11 887050/week @ 2024-08-18 906007/week @ 2024-08-25 889002/week @ 2024-09-01 917922/week @ 2024-09-08 860151/week @ 2024-09-15 968058/week @ 2024-09-22 959016/week @ 2024-09-29 1019675/week @ 2024-10-06 1005442/week @ 2024-10-13 1078455/week @ 2024-10-20 1060945/week @ 2024-10-27 1036740/week @ 2024-11-03

4,237,163 downloads per month
Used in 8,440 crates (52 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–24MB
~338K SLoC