@@ -89,8 +89,11 @@ class SingleConsumerEvent final {
8989 // /
9090 // / Waiter side:
9191 // / @snippet engine/single_consumer_event_test.cpp CV waiter
92+ // /
93+ // / @return `FutureStatus::kReady` if @a stop_waiting became `true`, `FutureStatus::kCancelled` if the current
94+ // / task was cancelled, `FutureStatus::kTimeout` if the deadline was reached.
9295 template <typename Predicate>
93- [[nodiscard]] bool WaitUntil (Deadline, Predicate stop_waiting);
96+ [[nodiscard]] FutureStatus WaitUntil (Deadline, Predicate stop_waiting);
9497
9598 // / Resets the signal flag, if there is any existing event. Guarantees at least 'acquire' and 'release'
9699 // / memory ordering. Must only be called by the waiting task.
@@ -139,7 +142,7 @@ bool SingleConsumerEvent::WaitForEventUntil(std::chrono::time_point<Clock, Durat
139142}
140143
141144template <typename Predicate>
142- bool SingleConsumerEvent::WaitUntil (Deadline deadline, Predicate stop_waiting) {
145+ FutureStatus SingleConsumerEvent::WaitUntil (Deadline deadline, Predicate stop_waiting) {
143146 // If the state, according to what we've been previously notified of via
144147 // 'Send', is OK, then return right away. Fresh state updates can also
145148 // leak to us here, but we should not rely on it.
@@ -151,8 +154,8 @@ bool SingleConsumerEvent::WaitUntil(Deadline deadline, Predicate stop_waiting) {
151154 // We may also receive false signals from cases when we are allowed
152155 // and unallowed to make progress in a rapid sequence, or when the notifier
153156 // thinks that we might be happy with the state, but we aren't.
154- if (! WaitForEventUntil (deadline)) {
155- return false ;
157+ if (const auto status = WaitUntil (deadline); status != FutureStatus:: kReady ) {
158+ return status ;
156159 }
157160
158161 if (!IsAutoReset ()) {
@@ -163,7 +166,7 @@ bool SingleConsumerEvent::WaitUntil(Deadline deadline, Predicate stop_waiting) {
163166 }
164167 }
165168
166- return true ;
169+ return FutureStatus:: kReady ;
167170}
168171
169172} // namespace engine
0 commit comments