#channel #threads #atomic

skipchannel

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

1 stable release

1.0.0 Sep 8, 2018

#10 in #threads

Download history 20/week @ 2018-09-30 14/week @ 2018-10-07 10/week @ 2018-10-14 35/week @ 2018-10-21 16/week @ 2018-10-28 14/week @ 2018-11-04 9/week @ 2018-11-11 27/week @ 2018-11-18 4/week @ 2018-11-25 17/week @ 2018-12-02 7/week @ 2018-12-09 4/week @ 2018-12-16 18/week @ 2018-12-23

3 downloads per month

BSD-3-Clause

8KB
180 lines


lib.rs:

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