21 stable releases

new 2.2.1 Apr 14, 2024
2.2.0 Feb 8, 2024
2.1.1 Nov 24, 2023
1.9.0 Jul 8, 2023
0.1.0 May 6, 2019

#9 in Concurrency

Download history 399948/week @ 2023-12-23 507863/week @ 2023-12-30 603112/week @ 2024-01-06 629127/week @ 2024-01-13 690021/week @ 2024-01-20 906495/week @ 2024-01-27 697366/week @ 2024-02-03 658705/week @ 2024-02-10 669789/week @ 2024-02-17 700651/week @ 2024-02-24 713495/week @ 2024-03-02 715144/week @ 2024-03-09 731273/week @ 2024-03-16 724737/week @ 2024-03-23 773524/week @ 2024-03-30 655974/week @ 2024-04-06

3,002,227 downloads per month
Used in 5,794 crates (365 directly)

Apache-2.0 OR MIT

40KB
556 lines

async-channel

Build License Cargo Documentation

An async multi-producer multi-consumer channel, where each message can be received by only one of all existing consumers.

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

~395KB