#channel #thread #atomic

skipchannel

skipchannels allow to communicate between threads, but always skip to the last sent value

3 stable releases

Uses old Rust 2015

2.0.1 Jul 22, 2020
2.0.0 Sep 18, 2018
1.0.0 Sep 8, 2018

#575 in Concurrency

BSD-3-Clause

9KB
180 lines

This crate allows you to create a skipchannel and use it to send values between threads. When you read from a skipchannel you'll only ever get the last sent value, i.e. the channel skips all intermediate values. (The idea for skipchannels comes from the Concurrent Haskell paper.)

Here's an example:

extern crate skipchannel;

use skipchannel::skipchannel;

let (sender, receiver) = skipchannel();
let thread = std::thread::spawn(move || {
  std::thread::sleep(std::time::Duration::new(0, 100_000_000));
  receiver.recv()
});
sender.send(1);
sender.send(2);
assert_eq!(thread.join().unwrap(), Some(2));

No runtime deps