Roll forward up to cl/355302206.

This commit is contained in:
hai007
2021-02-04 13:32:13 -08:00
parent cd992ba413
commit 48e1c47a93
41 changed files with 1194 additions and 472 deletions
+12
View File
@@ -1,5 +1,7 @@
#include "platform/base/cancellation_flag.h"
#include "platform/base/feature_flags.h"
namespace location {
namespace nearby {
@@ -15,6 +17,11 @@ CancellationFlag::CancellationFlag(bool cancelled) {
void CancellationFlag::Cancel() {
absl::MutexLock lock(mutex_.get());
// Return immediately as no-op if feature flag is not enabled.
if (!FeatureFlags::GetInstance().GetFlags().enable_cancellation_flag) {
return;
}
if (cancelled_) {
// Someone already cancelled. Return immediately.
return;
@@ -25,6 +32,11 @@ void CancellationFlag::Cancel() {
bool CancellationFlag::Cancelled() const {
absl::MutexLock lock(mutex_.get());
// Return falsea as no-op if feature flag is not enabled.
if (!FeatureFlags::GetInstance().GetFlags().enable_cancellation_flag) {
return false;
}
return cancelled_;
}