Giter VIP home page Giter VIP logo

atomicbox's Introduction

atomicbox

Safe atomic boxes.

Documentation Build Status

This crate provides AtomicBox<T> and AtomicOptionBox<T> types: safe, owning versions of the standard library's AtomicPtr.

Unfortunately, the only operations you can perform on an atomic box are swaps and stores: you can't just use the box without taking ownership of it. Imagine a Box without Deref or DerefMut implementations, and you'll get the idea. Still, this is sufficient for some lock-free data structures, so here it is!

Why no Deref?

It wouldn't be safe. The point of an AtomicBox is that other threads can obtain the boxed value, take ownership of it, even drop it, all without taking a lock. So there is no safe way to borrow that value—except to swap it out of the AtomicBox yourself.

This is pretty much the same reason you can't borrow a reference to the contents of any other atomic type. It would invite data races. The only difference here is that those contents happen to be on the heap.

License: MIT/Apache-2.0

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.