update_channel

Crates.ioupdate_channel
lib.rsupdate_channel
version0.1.3
sourcesrc
created_at2021-01-15 18:25:31.565889
updated_at2021-01-29 02:03:14.974482
descriptionA channel for single updatable values.
homepage
repositoryhttps://github.com/DrSloth/heartfelt
max_upload_size
id342483
size19,103
Hassan Abu-Jabir (DrSloth)

documentation

README

A channel for single updatable values. The Updater can update a shared value and a Receiver can then update it's own internal value.

Example:

    use update_channel::channel_with;
    use std::thread::spawn;

    let (mut receiver, updater) = channel_with(0);
    assert_eq!(*receiver.borrow(), 0);

    spawn(move || {
        updater.update(2).unwrap(); // shared value is 2
        updater.update(12).unwrap(); // shared value is 12
    })
    .join().unwrap();

    // Shared value is 2 but internal value is 0
    assert_eq!(*receiver.borrow(), 0);
    // Update the latest value
    receiver.recv_update().unwrap();
    // Shared value is 12 and internal value 12
    assert_eq!(*receiver.borrow(), 12);

update_channel is distributed under the terms of the MIT license.

See LICENSE for more details

Commit count: 20

cargo fmt