single_value_channel

Crates.iosingle_value_channel
lib.rssingle_value_channel
version1.2.2
sourcesrc
created_at2017-06-21 11:20:13.827738
updated_at2021-02-21 12:04:10.94615
descriptionConcurrent single-value update and receive channel
homepage
repositoryhttps://github.com/alexheretic/single-value-channel
max_upload_size
id19998
size24,515
Alex Butler (alexheretic)

documentation

README

single_value_channel crates.io Documentation

Non-blocking single value update and receive channel.

This module provides a latest-message style channel, where update sources can update the latest value that the receiver owns in a practically non-blocking way.

Unlike the mpsc::channel each value send will overwrite the 'latest' value. See the documentation for more details.

use single_value_channel::channel_starting_with;
use std::thread;

let (mut receiver, updater) = channel_starting_with(0);
assert_eq!(*receiver.latest(), 0);

thread::spawn(move|| {
    updater.update(2); // next access to receiver.latest() -> 2
    updater.update(12); // next access to receiver.latest() -> 12
}).join();

assert_eq!(*receiver.latest(), 12);

Minimum supported rust compiler

This crate is maintained with latest stable rust.

Commit count: 22

cargo fmt