Async multi-producer multi-consumer channel
Find a file
Jason Volk e990f0006b
Some checks failed
CI / test (ubuntu-latest, beta) (push) Failing after 3s
CI / test (ubuntu-latest, nightly) (push) Failing after 4s
CI / test (ubuntu-latest, stable) (push) Failing after 3s
CI / msrv (push) Failing after 3s
CI / clippy (push) Failing after 9s
CI / fmt (push) Has been cancelled
CI / security_audit (push) Has been cancelled
Add constructions with scheduling types from event-listener.
Signed-off-by: Jason Volk <jason@zemos.net>
2026-03-27 17:33:30 +00:00
.github Support portable atomic (#106) 2025-04-29 01:43:26 +09:00
src Add constructions with scheduling types from event-listener. 2026-03-27 17:33:30 +00:00
tests Add Sender::closed future (#102) 2025-07-06 14:26:58 +09:00
.gitignore Initial commit 2020-05-31 02:00:16 +02:00
Cargo.toml Release 2.5.0 2025-07-06 16:04:26 +09:00
CHANGELOG.md Release 2.5.0 2025-07-06 16:04:26 +09:00
LICENSE-APACHE Initial commit 2020-05-31 02:00:16 +02:00
LICENSE-MIT Initial commit 2020-05-31 02:00:16 +02:00
README.md Fix CI badge in README.md (#84) 2024-04-04 09:38:49 +09:00

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.