summaryrefslogtreecommitdiff
path: root/absl/synchronization/mutex.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-09-08 02:30:31 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-09-08 02:31:35 -0700
commit38afe317694fcc11fa9f4b27bd930023719cf699 (patch)
treef874c340383677a40818807766172ee1cd9754e4 /absl/synchronization/mutex.h
parent3cb94be9bea2eda6dd2d572d1cf074efcc48a20b (diff)
absl: remove special handling of Condition::kTrue
Condition::kTrue is used very rarely (frequently its uses even indicate confusion and bugs). But we pay few additional branches for kTrue on all Condition operations. Remove that special handling and simplify logic. PiperOrigin-RevId: 563691160 Change-Id: I76125adde4872489da069dd9c894ed73a65d1d83
Diffstat (limited to 'absl/synchronization/mutex.h')
-rw-r--r--absl/synchronization/mutex.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
index 645c26d9..f2bafa97 100644
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -807,10 +807,10 @@ class Condition {
#endif
// Function with which to evaluate callbacks and/or arguments.
- bool (*eval_)(const Condition*) = nullptr;
+ bool (*const eval_)(const Condition*);
// Either an argument for a function call or an object for a method call.
- void* arg_ = nullptr;
+ void* const arg_;
// Various functions eval_ can point to:
static bool CallVoidPtrFunction(const Condition*);
@@ -833,8 +833,10 @@ class Condition {
std::memcpy(callback, callback_, sizeof(*callback));
}
+ static bool AlwaysTrue(const Condition*) { return true; }
+
// Used only to create kTrue.
- constexpr Condition() = default;
+ constexpr Condition() : eval_(AlwaysTrue), arg_(nullptr) {}
};
// -----------------------------------------------------------------------------