Giter VIP home page Giter VIP logo

pinboard's Introduction

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

pinboard's People

Contributors

bors[bot] avatar bossmc avatar dependabot-preview[bot] avatar dependabot-support avatar pepyakin avatar tomchaplin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pinboard's Issues

Requires `AcqRel` for `set()` and `clear()`?

I think, in set() and clear(), it's necessary to swap self.0 with the AcqRel ordering (instead of Release). Because otherwise, guard.unlinked(t) is not necessarily happening after the initialization of the data contained in t.

For example, suppose that an invocation "A" of set() writes a value t and another invocation "B" of set() is replacing t. Then B's invocation of guard.unlinked(t) should happen after A's invocation of Owned::new(t). However, with only Release ordering we cannot guarantee that.

By the way, thank you for building this wonderful library. I needed pinboard in building a new version of Crossbeam, so I reimplemented it with the name AtomicBox: https://github.com/jeehoonkang/crossbeam-epoch/blob/hazard-pointer/src/sync/atomic_box.rs (warning: no documentation at all yet!) I'll properly acknowledge the pinboard crate before submitting it as a PR to crossbeam-epoch.

Destructors are not called when replacing a pinboards contents

When storing data in a pinboard, if the contents are replaced, the old data does not have the destructors called, this leads to a memory leak.

I have attached a crate which demonstrates the issue, this can be verified by running valgrind against the example (using nightly-2017-07-06 as later versions seem to be broken).

pinboard-test.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.