Giter Site home page Giter Site logo

spinning_top's People

Contributors

jannic avatar mkroening avatar notgull avatar phil-opp avatar toku-sa-n 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spinning_top's Issues

Reviews appreciated!

This crate is quite new and hasn't been reviewed by anyone yet. I would appreciate any reviews on the code especially on the unsafe implementation of the RawMutex trait:

unsafe impl RawMutex for RawSpinlock {
const INIT: RawSpinlock = RawSpinlock {
locked: AtomicBool::new(false),
};
// A spinlock guard can be sent to another thread and unlocked there
type GuardMarker = GuardSend;
fn lock(&self) {
while !self.try_lock() {
// Wait until the lock looks unlocked before retrying
// Code from https://github.com/mvdnes/spin-rs/commit/d3e60d19adbde8c8e9d3199c7c51e51ee5a20bf6
while self.locked.load(Ordering::Relaxed) {
// Tell the CPU that we're inside a busy-wait loop
spin_loop_hint();
}
}
}
fn try_lock(&self) -> bool {
self.locked
.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
.is_ok()
}
fn unlock(&self) {
self.locked.store(false, Ordering::Release);
}
}

Readers-writer lock

Basically, reviving #6.

Would you be interested in a PR adding a simple spinning RwLock? If concerned with minimalism, it could be behind a feature flag.

Add an RwLock equivalent to this crate

It would be nice if there was a spinlock equivalent of an RwLock in this crate as well. In my crate, I have the need of a read-write lock in a #![no_std] context. I am willing to implement this pull request.

spin-rs is now maintained

Hello! I've taken over maintenance of spin-rs. It now has support for lock_api and Send/Sync guards among other things. I doubt it'll have much bearing on spinning_top, but I thought you'd be interested in this (I'm told that spin-rs's lack of maintenance was the primary driving force behind this crate's development).

const fn Spinlock::new

It would be cool to have a way to construct a Spinlock in a const context. This would be super useful for a bunch of stuff I'm currently doing.

Exponential backoff

Would you be interested in a PR adding an exponential-backoff feature as a performance enhancement when running with a larger number of processors?

Add `arc_lock` feature

After #18, it might make sense to provide type aliases for all new lock_api guards, under the arc_lock feature flag.

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.