|
|
@ -21,9 +21,6 @@ |
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CCriticalSection mutex; |
|
|
|
CCriticalSection mutex; |
|
|
|
boost::recursive_mutex mutex; |
|
|
|
boost::recursive_mutex mutex; |
|
|
|
|
|
|
|
|
|
|
@ -42,20 +39,18 @@ ENTER_CRITICAL_SECTION(mutex); // no RAII |
|
|
|
|
|
|
|
|
|
|
|
LEAVE_CRITICAL_SECTION(mutex); // no RAII
|
|
|
|
LEAVE_CRITICAL_SECTION(mutex); // no RAII
|
|
|
|
mutex.unlock(); |
|
|
|
mutex.unlock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
///////////////////////////////
|
|
|
|
// //
|
|
|
|
// //
|
|
|
|
// THE ACTUAL IMPLEMENTATION //
|
|
|
|
// THE ACTUAL IMPLEMENTATION //
|
|
|
|
// //
|
|
|
|
// //
|
|
|
|
///////////////////////////////
|
|
|
|
///////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
// Template mixin that adds -Wthread-safety locking annotations to a
|
|
|
|
/**
|
|
|
|
// subset of the mutex API.
|
|
|
|
* Template mixin that adds -Wthread-safety locking |
|
|
|
|
|
|
|
* annotations to a subset of the mutex API. |
|
|
|
|
|
|
|
*/ |
|
|
|
template <typename PARENT> |
|
|
|
template <typename PARENT> |
|
|
|
class LOCKABLE AnnotatedMixin : public PARENT |
|
|
|
class LOCKABLE AnnotatedMixin : public PARENT |
|
|
|
{ |
|
|
|
{ |
|
|
@ -76,8 +71,10 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** Wrapped boost mutex: supports recursive locking, but no waiting */ |
|
|
|
/**
|
|
|
|
// TODO: We should move away from using the recursive lock by default.
|
|
|
|
* Wrapped boost mutex: supports recursive locking, but no waiting |
|
|
|
|
|
|
|
* TODO: We should move away from using the recursive lock by default. |
|
|
|
|
|
|
|
*/ |
|
|
|
typedef AnnotatedMixin<boost::recursive_mutex> CCriticalSection; |
|
|
|
typedef AnnotatedMixin<boost::recursive_mutex> CCriticalSection; |
|
|
|
|
|
|
|
|
|
|
|
/** Wrapped boost mutex: supports waiting but not recursive locking */ |
|
|
|
/** Wrapped boost mutex: supports waiting but not recursive locking */ |
|
|
@ -92,9 +89,7 @@ void LeaveCritical(); |
|
|
|
std::string LocksHeld(); |
|
|
|
std::string LocksHeld(); |
|
|
|
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs); |
|
|
|
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs); |
|
|
|
#else |
|
|
|
#else |
|
|
|
void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) |
|
|
|
void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {} |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void static inline LeaveCritical() {} |
|
|
|
void static inline LeaveCritical() {} |
|
|
|
void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) {} |
|
|
|
void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) {} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|