aboutsummaryrefslogtreecommitdiff
path: root/src/sync.h
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-09-06 20:59:58 +0200
committerJon Atack <jon@atack.com>2021-09-06 23:43:51 +0200
commit8d2f847ed913f15677ae978a412015ac844ffceb (patch)
treea773d0e75b49b4b5b301182b49a66f3aafee483f /src/sync.h
parent6718fbe90a0d9384c4d954b65f1fd4e69838d10c (diff)
downloadbitcoin-8d2f847ed913f15677ae978a412015ac844ffceb.tar.xz
sync: inline lock contention logging macro to fix time duration
Co-authored-by: Martin Ankerl <martin.ankerl@gmail.com>
Diffstat (limited to 'src/sync.h')
-rw-r--r--src/sync.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/sync.h b/src/sync.h
index bf15c0b4eb..6ba63d5e4d 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -6,6 +6,8 @@
#ifndef BITCOIN_SYNC_H
#define BITCOIN_SYNC_H
+#include <logging.h>
+#include <logging/timer.h>
#include <threadsafety.h>
#include <util/macros.h>
@@ -126,9 +128,6 @@ using RecursiveMutex = AnnotatedMixin<std::recursive_mutex>;
/** Wrapped mutex: supports waiting but not recursive locking */
typedef AnnotatedMixin<std::mutex> Mutex;
-/** Prints a lock contention to the log */
-void LockContention(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 UniqueLock : public Base
@@ -138,7 +137,7 @@ private:
{
EnterCritical(pszName, pszFile, nLine, Base::mutex());
if (Base::try_lock()) return;
- LockContention(pszName, pszFile, nLine); // log the contention
+ LOG_TIME_MICROS_WITH_CATEGORY(strprintf("lock contention %s, %s:%d", pszName, pszFile, nLine), BCLog::LOCK);
Base::lock();
}