5#include "flutter/fml/synchronization/waitable_event.h"
10#include "flutter/fml/logging.h"
11#include "flutter/fml/time/time_delta.h"
12#include "flutter/fml/time/time_point.h"
19template <
typename ConditionFn>
21 std::condition_variable* cv,
22 ConditionFn condition,
35 cv->wait_for(*locker, std::chrono::nanoseconds(
55 wait_remaining =
timeout - elapsed;
62 std::scoped_lock locker(mutex_);
68 std::scoped_lock locker(mutex_);
73 std::unique_lock<std::mutex> locker(mutex_);
81 std::unique_lock<std::mutex> locker(mutex_);
94 locker, std::chrono::nanoseconds(wait_remaining.
ToNanoseconds()))) {
113 wait_remaining =
timeout - elapsed;
121 std::scoped_lock locker(mutex_);
128 std::scoped_lock locker(mutex_);
135 std::scoped_lock locker(mutex_);
140 std::unique_lock<std::mutex> locker(mutex_);
146 auto last_signal_id = signal_id_;
149 }
while (signal_id_ == last_signal_id);
153 std::unique_lock<std::mutex> locker(mutex_);
155 auto last_signal_id = signal_id_;
162 [
this, last_signal_id]() {
164 return signaled_ || signal_id_ != last_signal_id;
167 FML_DCHECK(
rv || signaled_ || signal_id_ != last_signal_id);
172 std::scoped_lock locker(mutex_);
bool WaitWithTimeout(TimeDelta timeout)
bool WaitWithTimeout(TimeDelta timeout)
constexpr int64_t ToNanoseconds() const
#define FML_DCHECK(condition)
bool WaitWithTimeoutImpl(std::unique_lock< std::mutex > *locker, std::condition_variable *cv, ConditionFn condition, TimeDelta timeout)
def timeout(deadline, cmd)