diff --git a/src/logging.h b/src/logging.h --- a/src/logging.h +++ b/src/logging.h @@ -63,7 +63,7 @@ private: // Can not use Mutex from sync.h because in debug mode it would cause a // deadlock when a potential deadlock was detected - mutable std::mutex m_cs; + mutable StdMutex m_cs; FILE *m_fileout GUARDED_BY(m_cs) = nullptr; std::list m_msgs_before_open GUARDED_BY(m_cs); diff --git a/src/threadsafety.h b/src/threadsafety.h --- a/src/threadsafety.h +++ b/src/threadsafety.h @@ -59,12 +59,16 @@ #define ASSERT_EXCLUSIVE_LOCK(...) #endif // __GNUC__ +// StdMutex provides an annotated version of std::mutex for us, +// and should only be used when sync.h Mutex/LOCK/etc are not usable. +class LOCKABLE StdMutex : public std::mutex {}; + // LockGuard provides an annotated version of lock_guard for us // should only be used when sync.h Mutex/LOCK/etc aren't usable -class SCOPED_LOCKABLE LockGuard : public std::lock_guard { +class SCOPED_LOCKABLE LockGuard : public std::lock_guard { public: - explicit LockGuard(std::mutex &cs) EXCLUSIVE_LOCK_FUNCTION(cs) - : std::lock_guard(cs) {} + explicit LockGuard(StdMutex &cs) EXCLUSIVE_LOCK_FUNCTION(cs) + : std::lock_guard(cs) {} ~LockGuard() UNLOCK_FUNCTION(){}; };