#mpmc #mpsc #spmc #futures #chan

async-channel

Async multi-producer multi-consumer channel

7 releases (stable)

new 1.4.0 Jul 31, 2020
1.3.0 Jul 31, 2020
1.1.1 Jun 24, 2020
1.0.0 May 31, 2020
0.1.0 May 6, 2019

#182 in Concurrency

Download history 3/week @ 2020-04-15 1/week @ 2020-04-29 1/week @ 2020-05-06 1/week @ 2020-05-20 61/week @ 2020-05-27 154/week @ 2020-06-03 132/week @ 2020-06-10 387/week @ 2020-06-17 670/week @ 2020-06-24 1132/week @ 2020-07-01 1581/week @ 2020-07-08 7590/week @ 2020-07-15 20923/week @ 2020-07-22 23642/week @ 2020-07-29

14,540 downloads per month
Used in 546 crates (22 directly)

Apache-2.0 OR MIT

28KB
358 lines

async-channel

Build License Cargo Documentation

An async multi-producer multi-consumer channel.

There are two kinds of channels:

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

A channel has the Sender and Receiver side. Both sides are cloneable and can be shared among multiple threads.

When all Senders or all Receivers are dropped, the channel becomes closed. When a channel is closed, no more messages can be sent, but remaining messages can still be received.

The channel can also be closed manually by calling Sender::close() or Receiver::close().

Examples

let (s, r) = async_channel::unbounded();

assert_eq!(s.send("Hello").await, Ok(()));
assert_eq!(r.recv().await, Ok("Hello"));

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

~110KB