#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) decltype(g)::reverse_lock PASTE2(revlock, __COUNTER__)(g, #g, __FILE__, __LINE__) |
| |
| #define | LOCK(cs) DebugLock<decltype(cs)> PASTE2(criticalblock, __COUNTER__)(cs, #cs, __FILE__, __LINE__) |
| |
| #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) [&] { 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 > |
| |
◆ AssertLockHeld
| #define AssertLockHeld |
( |
|
cs | ) |
AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) |
◆ AssertLockNotHeld
| #define AssertLockNotHeld |
( |
|
cs | ) |
AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs) |
◆ ENTER_CRITICAL_SECTION
| #define ENTER_CRITICAL_SECTION |
( |
|
cs | ) |
|
Value: { \
EnterCritical(#cs, __FILE__, __LINE__, (void*)(&cs)); \
(cs).lock(); \
}
Definition at line 227 of file sync.h.
◆ LEAVE_CRITICAL_SECTION
| #define LEAVE_CRITICAL_SECTION |
( |
|
cs | ) |
|
Value: { \
(cs).unlock(); \
LeaveCritical(); \
}
Definition at line 233 of file sync.h.
◆ LOCK
| #define LOCK |
( |
|
cs | ) |
DebugLock<decltype(cs)> PASTE2(criticalblock, __COUNTER__)(cs, #cs, __FILE__, __LINE__) |
◆ LOCK2
| #define LOCK2 |
( |
|
cs1, |
|
|
|
cs2 |
|
) |
| |
Value: DebugLock<decltype(cs1)> criticalblock1(cs1, #cs1, __FILE__, __LINE__); \
DebugLock<decltype(cs2)> criticalblock2(cs2, #cs2, __FILE__, __LINE__);
Wrapper around std::unique_lock style lock for Mutex.
Definition at line 221 of file sync.h.
◆ REVERSE_LOCK
| #define REVERSE_LOCK |
( |
|
g | ) |
decltype(g)::reverse_lock PASTE2(revlock, __COUNTER__)(g, #g, __FILE__, __LINE__) |
◆ TRY_LOCK
◆ WAIT_LOCK
| #define WAIT_LOCK |
( |
|
cs, |
|
|
|
name |
|
) |
| DebugLock<decltype(cs)> name(cs, #cs, __FILE__, __LINE__) |
◆ WITH_LOCK
| #define WITH_LOCK |
( |
|
cs, |
|
|
|
code |
|
) |
| [&] { 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 115 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 112 of file sync.h.