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