summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-11-30 07:52:21 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2022-11-30 07:53:05 -0800
commit94e9ee3f75a617403049a29e6c932b8b3bb13177 (patch)
tree9620752289dc11bcb2699ac15942cecf9d44837f
parente7e31f278cc7a2d2ffdf0c1c078f4240253d3a63 (diff)
Remove static initializer from mutex.h.
PiperOrigin-RevId: 491915718 Change-Id: I7469601857b5a3506163518d29f49792f3053b34
-rw-r--r--absl/synchronization/mutex.cc3
-rw-r--r--absl/synchronization/mutex.h9
2 files changed, 6 insertions, 6 deletions
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc
index ddd8fb8d..c9d7c41a 100644
--- a/absl/synchronization/mutex.cc
+++ b/absl/synchronization/mutex.cc
@@ -2787,8 +2787,7 @@ static bool Dereference(void *arg) {
return *(static_cast<bool *>(arg));
}
-Condition::Condition() = default; // null constructor, used for kTrue only
-const Condition Condition::kTrue;
+ABSL_CONST_INIT const Condition Condition::kTrue;
Condition::Condition(bool (*func)(void *), void *arg)
: eval_(&CallVoidPtrFunction),
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
index 779aafa0..c6a85100 100644
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -729,7 +729,7 @@ class Condition {
: Condition(obj, static_cast<bool (T::*)() const>(&T::operator())) {}
// A Condition that always returns `true`.
- static const Condition kTrue;
+ ABSL_CONST_INIT static const Condition kTrue;
// Evaluates the condition.
bool Eval() const;
@@ -766,10 +766,10 @@ class Condition {
#endif
// Function with which to evaluate callbacks and/or arguments.
- bool (*eval_)(const Condition*);
+ bool (*eval_)(const Condition*) = nullptr;
// Either an argument for a function call or an object for a method call.
- void *arg_;
+ void *arg_ = nullptr;
// Various functions eval_ can point to:
static bool CallVoidPtrFunction(const Condition*);
@@ -790,7 +790,8 @@ class Condition {
std::memcpy(callback, callback_, sizeof(*callback));
}
- Condition(); // null constructor used only to create kTrue
+ // Used only to create kTrue.
+ constexpr Condition() = default;
};
// -----------------------------------------------------------------------------