Changeset View
Changeset View
Standalone View
Standalone View
src/sync.h
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
#ifdef DEBUG_LOCKORDER | #ifdef DEBUG_LOCKORDER | ||||
void EnterCritical(const char *pszName, const char *pszFile, int nLine, | void EnterCritical(const char *pszName, const char *pszFile, int nLine, | ||||
void *cs, bool fTry = false); | void *cs, bool fTry = false); | ||||
void LeaveCritical(); | void LeaveCritical(); | ||||
void CheckLastCritical(void *cs, std::string &lockname, const char *guardname, | void CheckLastCritical(void *cs, std::string &lockname, const char *guardname, | ||||
const char *file, int line); | const char *file, int line); | ||||
std::string LocksHeld(); | std::string LocksHeld(); | ||||
template <typename MutexType> | |||||
void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, | void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, | ||||
void *cs) ASSERT_EXCLUSIVE_LOCK(cs); | MutexType *cs) ASSERT_EXCLUSIVE_LOCK(cs); | ||||
void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | ||||
int nLine, void *cs); | int nLine, void *cs); | ||||
void DeleteLock(void *cs); | void DeleteLock(void *cs); | ||||
/** | /** | ||||
* Call abort() if a potential lock order deadlock bug is detected, instead of | * Call abort() if a potential lock order deadlock bug is detected, instead of | ||||
* just logging information and throwing a logic_error. Defaults to true, and | * just logging information and throwing a logic_error. Defaults to true, and | ||||
* set to false in DEBUG_LOCKORDER unit tests. | * set to false in DEBUG_LOCKORDER unit tests. | ||||
*/ | */ | ||||
extern bool g_debug_lockorder_abort; | extern bool g_debug_lockorder_abort; | ||||
#else | #else | ||||
static inline void EnterCritical(const char *pszName, const char *pszFile, | static inline void EnterCritical(const char *pszName, const char *pszFile, | ||||
int nLine, void *cs, bool fTry = false) {} | int nLine, void *cs, bool fTry = false) {} | ||||
static inline void LeaveCritical() {} | static inline void LeaveCritical() {} | ||||
static inline void CheckLastCritical(void *cs, std::string &lockname, | static inline void CheckLastCritical(void *cs, std::string &lockname, | ||||
const char *guardname, const char *file, | const char *guardname, const char *file, | ||||
int line) {} | int line) {} | ||||
template <typename MutexType> | |||||
static inline void AssertLockHeldInternal(const char *pszName, | static inline void AssertLockHeldInternal(const char *pszName, | ||||
const char *pszFile, int nLine, | const char *pszFile, int nLine, | ||||
void *cs) ASSERT_EXCLUSIVE_LOCK(cs) {} | MutexType *cs) | ||||
ASSERT_EXCLUSIVE_LOCK(cs) {} | |||||
static inline void AssertLockNotHeldInternal(const char *pszName, | static inline void AssertLockNotHeldInternal(const char *pszName, | ||||
const char *pszFile, int nLine, | const char *pszFile, int nLine, | ||||
void *cs) {} | void *cs) {} | ||||
static inline void DeleteLock(void *cs) {} | static inline void DeleteLock(void *cs) {} | ||||
#endif | #endif | ||||
#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) | #define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) | ||||
#define AssertLockNotHeld(cs) \ | #define AssertLockNotHeld(cs) \ | ||||
AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs) | AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs) | ||||
▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |