Giter Site home page Giter Site logo

qutex's People

Contributors

aldaronlau avatar c0gent avatar gallaghercommajack 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

qutex's Issues

TODOs

  • Consider adding a fast path for reads and writes which would not require creating a oneshot channel when queue is empty.
  • Wrap Canceled error in custom error type?

Detecting deadlock with single qutex/qrwlock

Here's example code which causes deadlock without unsafe code.

extern crate futures;
extern crate qutex;

use qutex::*;
use futures::prelude::*;

fn main() {
    let lock = QrwLock::from(0i32);

    let f = lock.clone().write().and_then(move |mut guard_w| {
        eprintln!("write lock acquired");
        lock.read().and_then(move |guard_r| {
            eprintln!("read lock acquired");

            let r0 = *guard_r;
            *guard_w += 1;
            let r1 = *guard_r;
            assert_eq!(r0, r1);
            Ok(())
        })
    });

    assert_eq!(Ok(()), f.wait());
}

Is there any way to detect the deadlock? It would be nice for FutureGuard to return Deadlocked error (just like Canceled error) if there's any prior FutureGuard which belongs to current task. In that case, above example will return Error(Deadlocked) on f.wait() instead of hanging on deadlock.

`Guard::unlock` leaves `Qutex` locked

The implementation of Guard::unlock actually leaves the lock still locked by canceling the Drop implementation for Guard. I believe a call to qutex.direct_unlock() is needed after the mem::forget for the function to work as intended.

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.