Expand description
A buffered channel similar to std::sync::mpsc::channel, but faster.
§Example
let (mut tx, mut rx) = bchan::channel::<u64>(4096);
std::thread::scope(|s| {
s.spawn(move || {
for i in 0..100000 {
tx.send(i);
}
});
s.spawn(move || {
let mut count = 0;
while let Some(x) = rx.recv() {
assert!( x == count );
count += 1;
}
});
});Structs§
Functions§
- channel
- Returns channel similar to mpsc::channel that buffers n elements.