HomePhabricator

Locking system overhaul, add condition variables
712fd182b72bUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

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.

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Apr 2 2012, 00:40
schancelPushed on Jan 5 2018, 21:58
schancelPushed on Jan 5 2018, 21:39
schancelPushed on Jan 5 2018, 21:17
Parents
rSTAGINGb0a7e05a45a9: Merge pull request #1019 from laanwj/2012_03_uirefactor
Branches
Unknown
Tags
Unknown

Event Timeline

Pieter Wuille <pieter.wuille@gmail.com> committed rSTAGING712fd182b72b: Locking system overhaul, add condition variables (authored by Pieter Wuille <pieter.wuille@gmail.com>).Apr 4 2012, 14:21