#single-value #channel

single_value_channel

Concurrent single-value update and receive channel

5 stable releases

1.2.2 Feb 21, 2021
1.2.1 Aug 26, 2019
1.2.0 Apr 4, 2019
1.1.0 Jun 29, 2017
1.0.0 Jun 21, 2017

#639 in Concurrency

Download history 2617/week @ 2025-09-21 2279/week @ 2025-09-28 2166/week @ 2025-10-05 130/week @ 2025-10-12 157/week @ 2025-10-19 102/week @ 2025-10-26 141/week @ 2025-11-02 115/week @ 2025-11-09 135/week @ 2025-11-16 256/week @ 2025-11-23 160/week @ 2025-11-30 162/week @ 2025-12-07 140/week @ 2025-12-14 81/week @ 2025-12-21 68/week @ 2025-12-28 145/week @ 2026-01-04

441 downloads per month
Used in 4 crates

Apache-2.0

13KB
212 lines

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.

No runtime deps