Changeset View
Changeset View
Standalone View
Standalone View
src/sync.h
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | 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) 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); | ||||
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 | ||||
static inline void EnterCritical(const char *pszName, const char *pszFile, | inline void EnterCritical(const char *pszName, const char *pszFile, int nLine, | ||||
int nLine, void *cs, bool fTry = false) {} | void *cs, bool fTry = false) {} | ||||
static inline void LeaveCritical() {} | inline void LeaveCritical() {} | ||||
static 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> | ||||
static inline void AssertLockHeldInternal(const char *pszName, | inline void AssertLockHeldInternal(const char *pszName, const char *pszFile, | ||||
const char *pszFile, int nLine, | int nLine, MutexType *cs) | ||||
MutexType *cs) | |||||
ASSERT_EXCLUSIVE_LOCK(cs) {} | ASSERT_EXCLUSIVE_LOCK(cs) {} | ||||
static inline void AssertLockNotHeldInternal(const char *pszName, | inline void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | ||||
const char *pszFile, int nLine, | int nLine, void *cs) {} | ||||
void *cs) {} | inline void DeleteLock(void *cs) {} | ||||
static inline void DeleteLock(void *cs) {} | inline bool LockStackEmpty() { | ||||
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) | ||||
/** | /** | ||||
* Template mixin that adds -Wthread-safety locking annotations and lock order | * Template mixin that adds -Wthread-safety locking annotations and lock order | ||||
* checking to a subset of the mutex API. | * checking to a subset of the mutex API. | ||||
▲ Show 20 Lines • Show All 279 Lines • Show Last 20 Lines |