summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-07-01 01:37:10 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-07-01 01:37:58 -0700
commitb1fb259ef793de57c2acefeeec07a6e3286ab9bc (patch)
tree4ea9ca7787b07e8b8294b32947b6155987f02a82 /absl
parent40070892631b82c79864ff4d3f7e12105f003157 (diff)
absl: extend Condition::kTrue comment
Explain when kTrue may be useful. Note that Mutex::Await/LockWhen with kTrue condition and a timeout do not return when the timeout is reached. PiperOrigin-RevId: 544846222 Change-Id: I7a14ae5a9314b2e500919f0c7b3a907d4d97c127
Diffstat (limited to 'absl')
-rw-r--r--absl/synchronization/mutex.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
index 2fd077c8..645c26d9 100644
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -760,6 +760,16 @@ class Condition {
: Condition(obj, static_cast<bool (T::*)() const>(&T::operator())) {}
// A Condition that always returns `true`.
+ // kTrue is only useful in a narrow set of circumstances, mostly when
+ // it's passed conditionally. For example:
+ //
+ // mu.LockWhen(some_flag ? kTrue : SomeOtherCondition);
+ //
+ // Note: {LockWhen,Await}With{Deadline,Timeout} methods with kTrue condition
+ // don't return immediately when the timeout happens, they still block until
+ // the Mutex becomes available. The return value of these methods does
+ // not indicate if the timeout was reached; rather it indicates whether or
+ // not the condition is true.
ABSL_CONST_INIT static const Condition kTrue;
// Evaluates the condition.