Reland "Replace RTC_WARN_UNUSED_RESULT with ABSL_MUST_USE_RESULT in c++ code"

This is a reland of 8c2250eddc7263036397179a0794b9b17d7afb38

Original change's description:
> Replace RTC_WARN_UNUSED_RESULT with ABSL_MUST_USE_RESULT in c++ code
>
> Bug: webrtc:12336
> Change-Id: If76f00d0883b5c8a90d3ef5554f5e22384b3fb58
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/197620
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32978}

Bug: webrtc:12336
Change-Id: I1cd017d45c1578528dec4532345950e9823f4a63
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201732
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33003}
This commit is contained in:
Danil Chapovalov
2021-01-14 16:15:31 +01:00
committed by Commit Bot
parent ba91dbcb3e
commit 098da17f35
13 changed files with 39 additions and 29 deletions

View File

@ -36,7 +36,6 @@ rtc_library("mutex") {
"..:checks",
"..:macromagic",
"..:platform_thread_types",
"../system:unused",
]
absl_deps = [ "//third_party/abseil-cpp/absl/base:core_headers" ]
if (rtc_use_absl_mutex) {

View File

@ -13,9 +13,9 @@
#include <atomic>
#include "absl/base/attributes.h"
#include "absl/base/const_init.h"
#include "rtc_base/checks.h"
#include "rtc_base/system/unused.h"
#include "rtc_base/thread_annotations.h"
#if defined(WEBRTC_ABSL_MUTEX)
@ -41,7 +41,7 @@ class RTC_LOCKABLE Mutex final {
void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() {
impl_.Lock();
}
RTC_WARN_UNUSED_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
ABSL_MUST_USE_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return impl_.TryLock();
}
void Unlock() RTC_UNLOCK_FUNCTION() {

View File

@ -11,6 +11,7 @@
#ifndef RTC_BASE_SYNCHRONIZATION_MUTEX_ABSEIL_H_
#define RTC_BASE_SYNCHRONIZATION_MUTEX_ABSEIL_H_
#include "absl/base/attributes.h"
#include "absl/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
@ -23,7 +24,7 @@ class RTC_LOCKABLE MutexImpl final {
MutexImpl& operator=(const MutexImpl&) = delete;
void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() { mutex_.Lock(); }
RTC_WARN_UNUSED_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
ABSL_MUST_USE_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return mutex_.TryLock();
}
void Unlock() RTC_UNLOCK_FUNCTION() { mutex_.Unlock(); }

View File

@ -23,6 +23,7 @@
#include <sal.h> // must come after windows headers.
// clang-format on
#include "absl/base/attributes.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
@ -37,7 +38,7 @@ class RTC_LOCKABLE MutexImpl final {
void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() {
EnterCriticalSection(&critical_section_);
}
RTC_WARN_UNUSED_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
ABSL_MUST_USE_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return TryEnterCriticalSection(&critical_section_) != FALSE;
}
void Unlock() RTC_UNLOCK_FUNCTION() {

View File

@ -18,6 +18,7 @@
#include <pthread_spis.h>
#endif
#include "absl/base/attributes.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
@ -39,7 +40,7 @@ class RTC_LOCKABLE MutexImpl final {
~MutexImpl() { pthread_mutex_destroy(&mutex_); }
void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() { pthread_mutex_lock(&mutex_); }
RTC_WARN_UNUSED_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
ABSL_MUST_USE_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return pthread_mutex_trylock(&mutex_) == 0;
}
void Unlock() RTC_UNLOCK_FUNCTION() { pthread_mutex_unlock(&mutex_); }