Coder Social home page Coder Social logo

upgrade_mutex's People

Contributors

howardhinnant avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

upgrade_mutex's Issues

Why there is no upgrade_lock< std::shared_lock<Mutex> >? Without time?

Why upgrade_lock have no

    upgrade_lock(std::shared_lock<mutex_type>&& sl)

constructor?

upgrade_mutex does not have unlock_shared_and_lock_upgrade, also. There is only timed version try_unlock_shared_and_lock_upgrade_for / try_unlock_shared_and_lock_upgrade_until.

P.S. It seems that boost have these timeless versions...

Issues with upgrade_mutex

  1. a. I believe that upgrade_mutex::try_unlock_shared_and_lock_until() should wait on gate1_ until there is no writer and no upgrader and then it should decrement the reader count and set the write_entered_ flag and then it should wait on gate2_ until there are no more readers. This prevents new readers from taking a shared or upgrade lock while this function is waiting to take the exclusive lock.
    b. Also, right now since it is only waiting on gate2_ it won't get signaled after any of the unlock*() functions are called.
  2. I believe that upgrade_mutex::try_unlock_shared_and_lock_upgrade_until() should wait on gate1_ instead of gate2_. Right now since it is only waiting on gate2_ it won't get signaled after unlock_upgrade() is called.
  3. a. I believe that upgrade_mutex::try_unlock_upgrade_and_lock_until() should decrement the reader count and set the write_entered_ flag and then it should wait on gate2_ until there are no more readers. This prevents new readers from taking a shared lock while this function is waiting to take the exclusive lock.
    b. Also, right now gate2_ only gets signaled when the reader count is zero but this function currently waits for the reader count to reach 1.

I've already fixed these issues in the copy of upgrade_mutex that exists in Boost.Thread: https://github.com/boostorg/thread/blob/develop/include/boost/thread/v2/shared_mutex.hpp.

Are these issues all valid or have I missed something? Thank you for taking a look at this.

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.