#include <threadsafety.h>
#include <util/macros.h>
#include <condition_variable>
#include <mutex>
#include <string>
#include <thread>
Go to the source code of this file.
|
#define | AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) |
|
#define | AssertLockNotHeld(cs) AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs) |
|
#define | REVERSE_LOCK(g) |
|
#define | LOCK(cs) |
|
#define | LOCK2(cs1, cs2) |
|
#define | TRY_LOCK(cs, name) DebugLock<decltype(cs)> name(cs, #cs, __FILE__, __LINE__, true) |
|
#define | WAIT_LOCK(cs, name) DebugLock<decltype(cs)> name(cs, #cs, __FILE__, __LINE__) |
|
#define | ENTER_CRITICAL_SECTION(cs) |
|
#define | LEAVE_CRITICAL_SECTION(cs) |
|
#define | WITH_LOCK(cs, code) |
| Run code while locking a mutex. More...
|
|
|
using | RecursiveMutex = AnnotatedMixin< std::recursive_mutex > |
| Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the recursive lock by default. More...
|
|
typedef AnnotatedMixin< std::mutex > | Mutex |
| Wrapped mutex: supports waiting but not recursive locking. More...
|
|
template<typename MutexArg > |
using | DebugLock = UniqueLock< typename std::remove_reference< typename std::remove_pointer< MutexArg >::type >::type > |
|
|
void | EnterCritical (const char *pszName, const char *pszFile, int nLine, void *cs, bool fTry=false) |
|
void | LeaveCritical () |
|
void | CheckLastCritical (void *cs, std::string &lockname, const char *guardname, const char *file, int line) |
|
template<typename MutexType > |
void | AssertLockHeldInternal (const char *pszName, const char *pszFile, int nLine, MutexType *cs) EXCLUSIVE_LOCKS_REQUIRED(cs) |
|
template<typename MutexType > |
void | AssertLockNotHeldInternal (const char *pszName, const char *pszFile, int nLine, MutexType *cs) LOCKS_EXCLUDED(cs) |
|
void | DeleteLock (void *cs) |
|
bool | LockStackEmpty () |
|
◆ AssertLockHeld
◆ AssertLockNotHeld
◆ ENTER_CRITICAL_SECTION
#define ENTER_CRITICAL_SECTION |
( |
|
cs | ) |
|
Value: { \
EnterCritical(#
cs, __FILE__, __LINE__, (
void *)(&
cs)); \
}
Definition at line 254 of file sync.h.
◆ LEAVE_CRITICAL_SECTION
#define LEAVE_CRITICAL_SECTION |
( |
|
cs | ) |
|
Value: { \
std::string lockname; \
CheckLastCritical((
void *)(&
cs), lockname, #
cs, __FILE__, __LINE__); \
LeaveCritical(); \
}
Definition at line 260 of file sync.h.
◆ LOCK
Value:
__COUNTER__)(
cs, #
cs, __FILE__, __LINE__)
Wrapper around std::unique_lock style lock for Mutex.
Definition at line 243 of file sync.h.
◆ LOCK2
#define LOCK2 |
( |
|
cs1, |
|
|
|
cs2 |
|
) |
| |
Value: DebugLock<decltype(cs1)> criticalblock1(cs1, #cs1, __FILE__, __LINE__); \
DebugLock<decltype(cs2)> criticalblock2(cs2, #cs2, __FILE__, __LINE__);
Definition at line 246 of file sync.h.
◆ REVERSE_LOCK
#define REVERSE_LOCK |
( |
|
g | ) |
|
Value: typename std::decay<decltype(g)>::type::reverse_lock
PASTE2( \
revlock, __COUNTER__)(g, #g, __FILE__, __LINE__)
Definition at line 235 of file sync.h.
◆ TRY_LOCK
◆ WAIT_LOCK
◆ WITH_LOCK
#define WITH_LOCK |
( |
|
cs, |
|
|
|
code |
|
) |
| |
◆ DebugLock
template<typename MutexArg >
using DebugLock = UniqueLock<typename std::remove_reference< typename std::remove_pointer<MutexArg>::type>::type> |
◆ Mutex
Wrapped mutex: supports waiting but not recursive locking.
Definition at line 133 of file sync.h.
◆ RecursiveMutex
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the recursive lock by default.
Definition at line 130 of file sync.h.
◆ AssertLockHeldInternal()
template<typename MutexType >
void AssertLockHeldInternal |
( |
const char * |
pszName, |
|
|
const char * |
pszFile, |
|
|
int |
nLine, |
|
|
MutexType * |
cs |
|
) |
| |
|
inline |
◆ AssertLockNotHeldInternal()
template<typename MutexType >
void AssertLockNotHeldInternal |
( |
const char * |
pszName, |
|
|
const char * |
pszFile, |
|
|
int |
nLine, |
|
|
MutexType * |
cs |
|
) |
| |
◆ CheckLastCritical()
void CheckLastCritical |
( |
void * |
cs, |
|
|
std::string & |
lockname, |
|
|
const char * |
guardname, |
|
|
const char * |
file, |
|
|
int |
line |
|
) |
| |
|
inline |
◆ DeleteLock()
void DeleteLock |
( |
void * |
cs | ) |
|
|
inline |
◆ EnterCritical()
void EnterCritical |
( |
const char * |
pszName, |
|
|
const char * |
pszFile, |
|
|
int |
nLine, |
|
|
void * |
cs, |
|
|
bool |
fTry = false |
|
) |
| |
|
inline |
◆ LeaveCritical()
◆ LockStackEmpty()