Changeset View
Changeset View
Standalone View
Standalone View
src/threadsafety.h
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#define NO_THREAD_SAFETY_ANALYSIS | #define NO_THREAD_SAFETY_ANALYSIS | ||||
#define ASSERT_EXCLUSIVE_LOCK(...) | #define ASSERT_EXCLUSIVE_LOCK(...) | ||||
#endif // __GNUC__ | #endif // __GNUC__ | ||||
// StdMutex provides an annotated version of std::mutex for us, | // StdMutex provides an annotated version of std::mutex for us, | ||||
// and should only be used when sync.h Mutex/LOCK/etc are not usable. | // and should only be used when sync.h Mutex/LOCK/etc are not usable. | ||||
class LOCKABLE StdMutex : public std::mutex {}; | class LOCKABLE StdMutex : public std::mutex {}; | ||||
// LockGuard provides an annotated version of lock_guard for us | // StdLockGuard provides an annotated version of std::lock_guard for us, | ||||
// should only be used when sync.h Mutex/LOCK/etc aren't usable | // and should only be used when sync.h Mutex/LOCK/etc are not usable. | ||||
class SCOPED_LOCKABLE LockGuard : public std::lock_guard<StdMutex> { | class SCOPED_LOCKABLE StdLockGuard : public std::lock_guard<StdMutex> { | ||||
public: | public: | ||||
explicit LockGuard(StdMutex &cs) EXCLUSIVE_LOCK_FUNCTION(cs) | explicit StdLockGuard(StdMutex &cs) EXCLUSIVE_LOCK_FUNCTION(cs) | ||||
: std::lock_guard<StdMutex>(cs) {} | : std::lock_guard<StdMutex>(cs) {} | ||||
~LockGuard() UNLOCK_FUNCTION(){}; | ~StdLockGuard() UNLOCK_FUNCTION() {} | ||||
}; | }; | ||||
#endif // BITCOIN_THREADSAFETY_H | #endif // BITCOIN_THREADSAFETY_H |