Changeset View
Changeset View
Standalone View
Standalone View
src/sync.h
Show First 20 Lines • Show All 61 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(); | ||||
std::string LocksHeld(); | std::string LocksHeld(); | ||||
void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, | void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine, | ||||
void *cs); | void *cs); | ||||
void AssertLockNotHeldInternal(const char *pszName, const char *pszFile, | |||||
int nLine, void *cs); | |||||
void DeleteLock(void *cs); | void DeleteLock(void *cs); | ||||
#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 AssertLockHeldInternal(const char *pszName, | static inline void AssertLockHeldInternal(const char *pszName, | ||||
const char *pszFile, int nLine, | const char *pszFile, int nLine, | ||||
void *cs) {} | void *cs) {} | ||||
static inline void AssertLockNotHeldInternal(const char *pszName, | |||||
const char *pszFile, int nLine, | |||||
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) \ | |||||
AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs) | |||||
/** | /** | ||||
* Wrapped mutex: supports recursive locking, but no waiting | * Wrapped mutex: supports recursive locking, but no waiting | ||||
* TODO: We should move away from using the recursive lock by default. | * TODO: We should move away from using the recursive lock by default. | ||||
*/ | */ | ||||
class CCriticalSection : public AnnotatedMixin<std::recursive_mutex> { | class CCriticalSection : public AnnotatedMixin<std::recursive_mutex> { | ||||
public: | public: | ||||
~CCriticalSection() { DeleteLock((void *)this); } | ~CCriticalSection() { DeleteLock((void *)this); } | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |