Changeset View
Changeset View
Standalone View
Standalone View
src/sync.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
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> | template <typename MutexType> | ||||
void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, | void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, | ||||
MutexType *cs); | MutexType *cs) EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
template <typename MutexType> | |||||
void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | ||||
int nLine, void *cs); | int nLine, MutexType *cs) | ||||
EXCLUSIVE_LOCKS_REQUIRED(!cs); | |||||
void DeleteLock(void *cs); | void DeleteLock(void *cs); | ||||
bool LockStackEmpty(); | bool LockStackEmpty(); | ||||
/** | /** | ||||
* 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 | ||||
inline void EnterCritical(const char *pszName, const char *pszFile, int nLine, | inline void EnterCritical(const char *pszName, const char *pszFile, int nLine, | ||||
void *cs, bool fTry = false) {} | void *cs, bool fTry = false) {} | ||||
inline void LeaveCritical() {} | inline void LeaveCritical() {} | ||||
inline void CheckLastCritical(void *cs, std::string &lockname, | 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> | template <typename MutexType> | ||||
inline void AssertLockHeldInternal(const char *pszName, const char *pszFile, | inline void AssertLockHeldInternal(const char *pszName, const char *pszFile, | ||||
int nLine, MutexType *cs) {} | int nLine, MutexType *cs) | ||||
inline void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | EXCLUSIVE_LOCKS_REQUIRED(cs) {} | ||||
int nLine, void *cs) {} | template <typename MutexType> | ||||
void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | |||||
int nLine, MutexType *cs) | |||||
EXCLUSIVE_LOCKS_REQUIRED(!cs) {} | |||||
inline void DeleteLock(void *cs) {} | inline void DeleteLock(void *cs) {} | ||||
inline bool LockStackEmpty() { | inline bool LockStackEmpty() { | ||||
return true; | return true; | ||||
} | } | ||||
#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 283 Lines • Show Last 20 Lines |