Permalink
Browse files

Fix DEBUG_LOCKCONTENTION

  • Loading branch information...
TheBlueMatt committed Jun 5, 2012
1 parent 4526820 commit 4d009243cbc2dd5aa172fedbd00c6658ae6ac82d
Showing with 13 additions and 2 deletions.
  1. +8 −0 src/sync.cpp
  2. +5 −2 src/sync.h
View
@@ -7,6 +7,14 @@
#include <boost/foreach.hpp>
+#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.
View
@@ -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<typename Mutex>
class CMutexLock
@@ -43,8 +47,7 @@ class CMutexLock
#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

0 comments on commit 4d00924

Please sign in to comment.