Skip to content

A threadsafe way to publish data, just stick it on the pinboard

License

Notifications You must be signed in to change notification settings

bossmc/pinboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pinboard

Crates.io - Pinboard Build Status Bors enabled License: MIT

An eventually-consistent, lock-free, mutable store of shared data.

Just stick it on the pinboard!

Documentation

https://docs.rs/pinboard/

Usage

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));
    }
  });
});

About

A threadsafe way to publish data, just stick it on the pinboard

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages