Crates.io | pinboard |
lib.rs | pinboard |
version | 2.2.0 |
source | src |
created_at | 2017-05-30 00:12:51.002634 |
updated_at | 2023-04-17 17:41:54.356113 |
description | A lock-free, threadsafe way to publish data, just stick it on the pinboard |
homepage | |
repository | https://github.com/bossmc/pinboard |
max_upload_size | |
id | 16845 |
size | 18,151 |
An eventually-consistent, lock-free, mutable store of shared data.
Just stick it on the pinboard!
Install from crates.io by adding pinboard
to your Cargo.toml
:
[dependencies]
pinboard = "2.0.0"
Now you can create a Pinboard, share it between your users (be they Futures
, threads or really anything else) and start sharing data!
use pinboard::NonEmptyPinboard;
use std::{thread, time::Duration};
let weather_report = NonEmptyPinboard::new("Sunny");
crossbeam::scope(|scope| {
scope.spawn(|_| {
thread::sleep(Duration::from_secs(10));
weather_report.set("Raining");
});
scope.spawn(|_| {
loop {
println!("The weather is {}", weather_report.get_ref());
thread::sleep(Duration::from_secs(1));
}
});
});