Condition variables instead of polling #1033

pull sipa wants to merge 2 commits into bitcoin:master from sipa:wait changing 3 files +132 −122
  1. sipa commented at 3:36 PM on April 4, 2012: member

    See the commit messages for more details.

  2. Locking system overhaul, add condition variables
    This commit simplifies the locking system: CCriticalSection becomes a
    simple typedef for boost::interprocess::interprocess_recursive_mutex,
    and CCriticalBlock and CTryCriticalBlock are replaced by a templated
    CMutexLock, which wraps boost::interprocess::scoped_lock.
    
    By making the lock type a template parameter, some critical sections
    can now be changed to non-recursive locks, which support waiting via
    condition variables. These are implemented in CWaitableCriticalSection
    and WAITABLE_CRITICAL_BLOCK.
    
    CWaitableCriticalSection is a wrapper for a different Boost mutex,
    which supports waiting/notification via condition variables. This
    should enable us to remove much of the used polling code. Important
    is that this mutex is not recursive, so functions that perform the
    locking must not call eachother.
    
    Because boost::interprocess::scoped_lock does not support assigning
    and copying, I had to revert to the older CRITICAL_BLOCK macros that
    use a nested for loop instead of a simple if.
    712fd182b7
  3. Condition variable for outbound connection slots
    Keep a global counter for nOutbound, protected with its own waitable
    critical section, and wait when all outbound slots are filled, rather
    than polling.
    
    This removes the (on average) 1 second delay between a lost connection
    and a new connection attempt, and may speed up shutdowns.
    092631f0ba
  4. gavinandresen commented at 4:37 PM on April 5, 2012: contributor

    ACK. Survives my testnet-in-a-box stress tests.

  5. sipa referenced this in commit 9362da78b0 on Apr 6, 2012
  6. sipa merged this on Apr 6, 2012
  7. sipa closed this on Apr 6, 2012

  8. coblee referenced this in commit ae7f5cfebc on Jul 17, 2012
  9. suprnurd referenced this in commit ec239ffa36 on Dec 5, 2017
  10. ptschip referenced this in commit 7c5ae144a8 on Apr 18, 2018
  11. lateminer referenced this in commit c04f442e4c on Nov 14, 2019
  12. DrahtBot locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 09:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me