Changeset View
Changeset View
Standalone View
Standalone View
src/sync.h
Show All 13 Lines | |||||
///////////////////////////////////////////////// | ///////////////////////////////////////////////// | ||||
// // | // // | ||||
// THE SIMPLE DEFINITION, EXCLUDING DEBUG CODE // | // THE SIMPLE DEFINITION, EXCLUDING DEBUG CODE // | ||||
// // | // // | ||||
///////////////////////////////////////////////// | ///////////////////////////////////////////////// | ||||
/* | /* | ||||
CCriticalSection mutex; | RecursiveMutex mutex; | ||||
std::recursive_mutex mutex; | std::recursive_mutex mutex; | ||||
LOCK(mutex); | LOCK(mutex); | ||||
std::unique_lock<std::recursive_mutex> criticalblock(mutex); | std::unique_lock<std::recursive_mutex> criticalblock(mutex); | ||||
LOCK2(mutex1, mutex2); | LOCK2(mutex1, mutex2); | ||||
std::unique_lock<std::recursive_mutex> criticalblock1(mutex1); | std::unique_lock<std::recursive_mutex> criticalblock1(mutex1); | ||||
std::unique_lock<std::recursive_mutex> criticalblock2(mutex2); | std::unique_lock<std::recursive_mutex> criticalblock2(mutex2); | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | public: | ||||
using UniqueLock = std::unique_lock<PARENT>; | using UniqueLock = std::unique_lock<PARENT>; | ||||
}; | }; | ||||
/** | /** | ||||
* 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. | ||||
*/ | */ | ||||
using RecursiveMutex = AnnotatedMixin<std::recursive_mutex>; | |||||
typedef AnnotatedMixin<std::recursive_mutex> CCriticalSection; | typedef AnnotatedMixin<std::recursive_mutex> CCriticalSection; | ||||
/** Wrapped mutex: supports waiting but not recursive locking */ | /** Wrapped mutex: supports waiting but not recursive locking */ | ||||
typedef AnnotatedMixin<std::mutex> Mutex; | typedef AnnotatedMixin<std::mutex> Mutex; | ||||
#ifdef DEBUG_LOCKCONTENTION | #ifdef DEBUG_LOCKCONTENTION | ||||
void PrintLockContention(const char *pszName, const char *pszFile, int nLine); | void PrintLockContention(const char *pszName, const char *pszFile, int nLine); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |