See the commit messages for more details.
Condition variables instead of polling #1033
pull sipa wants to merge 2 commits into bitcoin:master from sipa:wait changing 3 files +132 −122-
sipa commented at 3:36 PM on April 4, 2012: member
-
712fd182b7
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.
-
092631f0ba
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.
-
gavinandresen commented at 4:37 PM on April 5, 2012: contributor
ACK. Survives my testnet-in-a-box stress tests.
- sipa referenced this in commit 9362da78b0 on Apr 6, 2012
- sipa merged this on Apr 6, 2012
- sipa closed this on Apr 6, 2012
- coblee referenced this in commit ae7f5cfebc on Jul 17, 2012
- suprnurd referenced this in commit ec239ffa36 on Dec 5, 2017
- ptschip referenced this in commit 7c5ae144a8 on Apr 18, 2018
- lateminer referenced this in commit c04f442e4c on Nov 14, 2019
- DrahtBot locked this on Sep 8, 2021
Contributors