mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
scripted-diff: Small locking rename
Call sync.h primitives "locks" and "mutexes" instead of "blocks" and "waitable
critical sections" to match current coding conventions and c++11 standard
names.
This PR does not rename the "CCriticalSection" class (though this could be done
as a followup) because it is used everywhere and would swamp the other changes
in this PR. Plain mutexes should mostly be preferred instead of recursive
mutexes in new code anyway.
-BEGIN VERIFY SCRIPT-
set -x
set -e
ren() { git grep -l $1 | xargs sed -i s/$1/$2/; }
ren CCriticalBlock UniqueLock
ren CWaitableCriticalSection Mutex
ren CConditionVariable std::condition_variable
ren cs_GenesisWait g_genesis_wait_mutex
ren condvar_GenesisWait g_genesis_wait_cv
perl -0777 -pi -e 's/.*typedef.*condition_variable.*\n\n?//g' src/sync.h
-END VERIFY SCRIPT-
This commit is contained in:
15
src/sync.h
15
src/sync.h
@@ -107,10 +107,7 @@ public:
|
||||
typedef AnnotatedMixin<std::recursive_mutex> CCriticalSection;
|
||||
|
||||
/** Wrapped mutex: supports waiting but not recursive locking */
|
||||
typedef AnnotatedMixin<std::mutex> CWaitableCriticalSection;
|
||||
|
||||
/** Just a typedef for std::condition_variable, can be wrapped later if desired */
|
||||
typedef std::condition_variable CConditionVariable;
|
||||
typedef AnnotatedMixin<std::mutex> Mutex;
|
||||
|
||||
#ifdef DEBUG_LOCKCONTENTION
|
||||
void PrintLockContention(const char* pszName, const char* pszFile, int nLine);
|
||||
@@ -118,7 +115,7 @@ void PrintLockContention(const char* pszName, const char* pszFile, int nLine);
|
||||
|
||||
/** Wrapper around std::unique_lock style lock for Mutex. */
|
||||
template <typename Mutex, typename Base = typename Mutex::UniqueLock>
|
||||
class SCOPED_LOCKABLE CCriticalBlock : public Base
|
||||
class SCOPED_LOCKABLE UniqueLock : public Base
|
||||
{
|
||||
private:
|
||||
void Enter(const char* pszName, const char* pszFile, int nLine)
|
||||
@@ -144,7 +141,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
CCriticalBlock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) EXCLUSIVE_LOCK_FUNCTION(mutexIn) : Base(mutexIn, std::defer_lock)
|
||||
UniqueLock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) EXCLUSIVE_LOCK_FUNCTION(mutexIn) : Base(mutexIn, std::defer_lock)
|
||||
{
|
||||
if (fTry)
|
||||
TryEnter(pszName, pszFile, nLine);
|
||||
@@ -152,7 +149,7 @@ public:
|
||||
Enter(pszName, pszFile, nLine);
|
||||
}
|
||||
|
||||
CCriticalBlock(Mutex* pmutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) EXCLUSIVE_LOCK_FUNCTION(pmutexIn)
|
||||
UniqueLock(Mutex* pmutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) EXCLUSIVE_LOCK_FUNCTION(pmutexIn)
|
||||
{
|
||||
if (!pmutexIn) return;
|
||||
|
||||
@@ -163,7 +160,7 @@ public:
|
||||
Enter(pszName, pszFile, nLine);
|
||||
}
|
||||
|
||||
~CCriticalBlock() UNLOCK_FUNCTION()
|
||||
~UniqueLock() UNLOCK_FUNCTION()
|
||||
{
|
||||
if (Base::owns_lock())
|
||||
LeaveCritical();
|
||||
@@ -176,7 +173,7 @@ public:
|
||||
};
|
||||
|
||||
template<typename MutexArg>
|
||||
using DebugLock = CCriticalBlock<typename std::remove_reference<typename std::remove_pointer<MutexArg>::type>::type>;
|
||||
using DebugLock = UniqueLock<typename std::remove_reference<typename std::remove_pointer<MutexArg>::type>::type>;
|
||||
|
||||
#define PASTE(x, y) x ## y
|
||||
#define PASTE2(x, y) PASTE(x, y)
|
||||
|
||||
Reference in New Issue
Block a user