Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | List of all members
fml::ManualResetWaitableEvent Class Referencefinal

#include <waitable_event.h>

Public Member Functions

 ManualResetWaitableEvent ()
 
 ~ManualResetWaitableEvent ()
 
void Reset ()
 
void Signal ()
 
void Wait ()
 
bool WaitWithTimeout (TimeDelta timeout)
 
bool IsSignaledForTest ()
 

Detailed Description

Definition at line 80 of file waitable_event.h.

Constructor & Destructor Documentation

◆ ManualResetWaitableEvent()

fml::ManualResetWaitableEvent::ManualResetWaitableEvent ( )
inline

Definition at line 82 of file waitable_event.h.

82{}

◆ ~ManualResetWaitableEvent()

fml::ManualResetWaitableEvent::~ManualResetWaitableEvent ( )
inline

Definition at line 83 of file waitable_event.h.

83{}

Member Function Documentation

◆ IsSignaledForTest()

bool fml::ManualResetWaitableEvent::IsSignaledForTest ( )

Definition at line 171 of file waitable_event.cc.

171 {
172 std::scoped_lock locker(mutex_);
173 return signaled_;
174}

◆ Reset()

void fml::ManualResetWaitableEvent::Reset ( )

Definition at line 134 of file waitable_event.cc.

134 {
135 std::scoped_lock locker(mutex_);
136 signaled_ = false;
137}

◆ Signal()

void fml::ManualResetWaitableEvent::Signal ( )

Definition at line 127 of file waitable_event.cc.

127 {
128 std::scoped_lock locker(mutex_);
129 signaled_ = true;
130 signal_id_++;
131 cv_.notify_all();
132}

◆ Wait()

void fml::ManualResetWaitableEvent::Wait ( )

Definition at line 139 of file waitable_event.cc.

139 {
140 std::unique_lock<std::mutex> locker(mutex_);
141
142 if (signaled_) {
143 return;
144 }
145
146 auto last_signal_id = signal_id_;
147 do {
148 cv_.wait(locker);
149 } while (signal_id_ == last_signal_id);
150}

◆ WaitWithTimeout()

bool fml::ManualResetWaitableEvent::WaitWithTimeout ( TimeDelta  timeout)

Definition at line 152 of file waitable_event.cc.

152 {
153 std::unique_lock<std::mutex> locker(mutex_);
154
155 auto last_signal_id = signal_id_;
156 // Disable thread-safety analysis for the lambda: We could annotate it with
157 // |FML_EXCLUSIVE_LOCKS_REQUIRED(mutex_)|, but then the analyzer currently
158 // isn't able to figure out that |WaitWithTimeoutImpl()| calls it while
159 // holding |mutex_|.
160 bool rv = WaitWithTimeoutImpl(
161 &locker, &cv_,
162 [this, last_signal_id]() {
163 // Also check |signaled_| in case we're already signaled.
164 return signaled_ || signal_id_ != last_signal_id;
165 },
166 timeout);
167 FML_DCHECK(rv || signaled_ || signal_id_ != last_signal_id);
168 return rv;
169}
#define FML_DCHECK(condition)
Definition: logging.h:103
bool WaitWithTimeoutImpl(std::unique_lock< std::mutex > *locker, std::condition_variable *cv, ConditionFn condition, TimeDelta timeout)
def timeout(deadline, cmd)

The documentation for this class was generated from the following files: