diff options
author | Chris Kennelly <ckennelly@google.com> | 2024-03-13 10:51:20 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-03-13 10:52:13 -0700 |
commit | e4b07ec1fc6885eca8a1d8d2439a6554b4a81378 (patch) | |
tree | 320dd59a6067da11ea38e82a08f8d5cee70f7b75 | |
parent | 321addf0511571e9910dc13a25221473656419d4 (diff) | |
download | abseil-e4b07ec1fc6885eca8a1d8d2439a6554b4a81378.tar.gz abseil-e4b07ec1fc6885eca8a1d8d2439a6554b4a81378.tar.bz2 abseil-e4b07ec1fc6885eca8a1d8d2439a6554b4a81378.zip |
Add nodiscard to SpinLockHolder.
PiperOrigin-RevId: 615473765
Change-Id: I03c3c16a0e178fce8a572ce272b7e1fd806a38a7
-rw-r--r-- | absl/base/internal/spinlock.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/absl/base/internal/spinlock.h b/absl/base/internal/spinlock.h index 36f823ad..301c3e3b 100644 --- a/absl/base/internal/spinlock.h +++ b/absl/base/internal/spinlock.h @@ -202,6 +202,15 @@ class ABSL_LOCKABLE ABSL_ATTRIBUTE_WARN_UNUSED SpinLock { // Corresponding locker object that arranges to acquire a spinlock for // the duration of a C++ scope. +// +// TODO(b/176172494): Use only [[nodiscard]] when baseline is raised. +// TODO(b/6695610): Remove forward declaration when #ifdef is no longer needed. +#if ABSL_HAVE_CPP_ATTRIBUTE(nodiscard) +class [[nodiscard]] SpinLockHolder; +#else +class ABSL_MUST_USE_RESULT ABSL_ATTRIBUTE_TRIVIAL_ABI SpinLockHolder; +#endif + class ABSL_SCOPED_LOCKABLE SpinLockHolder { public: inline explicit SpinLockHolder(SpinLock* l) ABSL_EXCLUSIVE_LOCK_FUNCTION(l) |