mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-07 14:18:18 +02:00
threading: never require logging from sync.h
sync.h is low-level and should not require any other subsystems. Move the lone remaining logging call to the .cpp. Any cost incurred by an additional function call should be trivial compared to the logging itself.
This commit is contained in:
14
src/sync.cpp
14
src/sync.cpp
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <sync.h>
|
||||
|
||||
#include <logging/timer.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/log.h>
|
||||
#include <util/strencodings.h>
|
||||
@@ -19,6 +20,19 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifdef DEBUG_LOCKCONTENTION
|
||||
|
||||
template <typename LockType>
|
||||
void ContendedLock(std::string_view name, std::string_view file, int nLine, LockType& lock)
|
||||
{
|
||||
LOG_TIME_MICROS_WITH_CATEGORY(strprintf("lock contention %s, %s:%d", name, file, nLine), BCLog::LOCK);
|
||||
lock.lock();
|
||||
}
|
||||
template void ContendedLock(std::string_view name, std::string_view file, int nLine, std::unique_lock<std::mutex>& lock);
|
||||
template void ContendedLock(std::string_view name, std::string_view file, int nLine, std::unique_lock<std::recursive_mutex>& lock);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
//
|
||||
// Early deadlock detection.
|
||||
|
||||
Reference in New Issue
Block a user