Crates.io | doublecross |
lib.rs | doublecross |
version | 0.2.1 |
source | src |
created_at | 2018-09-21 21:53:51.813646 |
updated_at | 2018-09-21 23:09:40.807259 |
description | Bi-directional channels for rust based on crossbeam-channel |
homepage | https://github.com/oefd/doublecross |
repository | https://github.com/oefd/doublecross |
max_upload_size | |
id | 85884 |
size | 24,933 |
Bi-directional channels for communicating between threads based on crossbeam-channel.
let (left, right) = unbounded::<bool, i32>();
thread::spawn(move || {
loop {
let val = right.recv().unwrap();
right.send(val % 2 == 0);
}
});
for i in 0..10 {
left.send(i);
if left.recv().unwrap() {
println!("{} is even", i);
}
}
[dependencies]
doublecross = "0.2"
Licensed under the terms of of the MPL-2.0.