diff --git a/src/sync.cpp b/src/sync.cpp index f2403a43f..dbd9ebdae 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -7,6 +7,14 @@ #include +#ifdef DEBUG_LOCKCONTENTION +void PrintLockContention(const char* pszName, const char* pszFile, int nLine) +{ + printf("LOCKCONTENTION: %s\n", pszName); + printf("Locker: %s:%d\n", pszFile, nLine); +} +#endif /* DEBUG_LOCKCONTENTION */ + #ifdef DEBUG_LOCKORDER // // Early deadlock detection. diff --git a/src/sync.h b/src/sync.h index dffe4f6ee..98640e6ea 100644 --- a/src/sync.h +++ b/src/sync.h @@ -27,6 +27,10 @@ void static inline EnterCritical(const char* pszName, const char* pszFile, int n void static inline LeaveCritical() {} #endif +#ifdef DEBUG_LOCKCONTENTION +void PrintLockContention(const char* pszName, const char* pszFile, int nLine); +#endif + /** Wrapper around boost::interprocess::scoped_lock */ template class CMutexLock @@ -43,8 +47,7 @@ public: #ifdef DEBUG_LOCKCONTENTION if (!lock.try_lock()) { - printf("LOCKCONTENTION: %s\n", pszName); - printf("Locker: %s:%d\n", pszFile, nLine); + PrintLockContention(pszName, pszFile, nLine); #endif lock.lock(); #ifdef DEBUG_LOCKCONTENTION