Crates.io | sorted-channel |
lib.rs | sorted-channel |
version | 0.1.1 |
source | src |
created_at | 2023-03-31 14:11:56.261 |
updated_at | 2023-03-31 14:20:35.781505 |
description | sorted message-based communication channel |
homepage | |
repository | https://github.com/kczimm/sorted-channel |
max_upload_size | |
id | 826431 |
size | 27,790 |
A multi-producer, multi-consumer channel that outputs sorted messages. Each message is received by only one receiving channel.
use sorted_channel::sorted_channel;
use std::thread;
let (tx, rx) = sorted_channel();
let handle = thread::spawn(move || {
for i in [0, 9, 1, 8, 2, 7, 3, 6, 4, 5] {
tx.send(i).unwrap();
}
});
handle.join().unwrap();
for i in (0..10).rev() {
assert_eq!(rx.recv(), Ok(i));
}
Licensed under either of
at your option.
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.