From 8a3ae1b6f5fb8a034408cc665f4ce1bf7a5e190d Mon Sep 17 00:00:00 2001 From: Chris Kennelly Date: Thu, 25 Apr 2024 08:57:21 -0700 Subject: Apply ABSL_MUST_USE_RESULT to try lock functions. PiperOrigin-RevId: 628091370 Change-Id: I2dd20b7f33ab99e78d63688832ab475a513aa3fd --- absl/synchronization/mutex.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'absl/synchronization') diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h index 95052252..be3f1f56 100644 --- a/absl/synchronization/mutex.h +++ b/absl/synchronization/mutex.h @@ -190,7 +190,7 @@ class ABSL_LOCKABLE ABSL_ATTRIBUTE_WARN_UNUSED Mutex { // If the mutex can be acquired without blocking, does so exclusively and // returns `true`. Otherwise, returns `false`. Returns `true` with high // probability if the `Mutex` was free. - bool TryLock() ABSL_EXCLUSIVE_TRYLOCK_FUNCTION(true); + ABSL_MUST_USE_RESULT bool TryLock() ABSL_EXCLUSIVE_TRYLOCK_FUNCTION(true); // Mutex::AssertHeld() // @@ -255,7 +255,7 @@ class ABSL_LOCKABLE ABSL_ATTRIBUTE_WARN_UNUSED Mutex { // If the mutex can be acquired without blocking, acquires this mutex for // shared access and returns `true`. Otherwise, returns `false`. Returns // `true` with high probability if the `Mutex` was free or shared. - bool ReaderTryLock() ABSL_SHARED_TRYLOCK_FUNCTION(true); + ABSL_MUST_USE_RESULT bool ReaderTryLock() ABSL_SHARED_TRYLOCK_FUNCTION(true); // Mutex::AssertReaderHeld() // @@ -281,7 +281,8 @@ class ABSL_LOCKABLE ABSL_ATTRIBUTE_WARN_UNUSED Mutex { void WriterUnlock() ABSL_UNLOCK_FUNCTION() { this->Unlock(); } - bool WriterTryLock() ABSL_EXCLUSIVE_TRYLOCK_FUNCTION(true) { + ABSL_MUST_USE_RESULT bool WriterTryLock() + ABSL_EXCLUSIVE_TRYLOCK_FUNCTION(true) { return this->TryLock(); } -- cgit v1.2.3