aboutsummaryrefslogtreecommitdiff
path: root/src/threadsafety.h
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-06-09 16:50:45 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-06-11 15:49:39 +0300
commitf8213c05f087e5fbb5d92a291f766b0baebc798f (patch)
tree37ef4f10f4c84aca2cec499bb1b268c493a2239b /src/threadsafety.h
parent45a6811d36fc59ce0d7e2be7a848059a05b0486e (diff)
downloadbitcoin-f8213c05f087e5fbb5d92a291f766b0baebc798f.tar.xz
Add means to handle negative capabilities in thread safety annotations
Diffstat (limited to 'src/threadsafety.h')
-rw-r--r--src/threadsafety.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/threadsafety.h b/src/threadsafety.h
index 942aa3fdcd..5f2c40bac6 100644
--- a/src/threadsafety.h
+++ b/src/threadsafety.h
@@ -60,6 +60,13 @@
// and should only be used when sync.h Mutex/LOCK/etc are not usable.
class LOCKABLE StdMutex : public std::mutex
{
+public:
+#ifdef __clang__
+ //! For negative capabilities in the Clang Thread Safety Analysis.
+ //! A negative requirement uses the EXCLUSIVE_LOCKS_REQUIRED attribute, in conjunction
+ //! with the ! operator, to indicate that a mutex should not be held.
+ const StdMutex& operator!() const { return *this; }
+#endif // __clang__
};
// StdLockGuard provides an annotated version of std::lock_guard for us,