Flutter Engine
fml::AutoResetWaitableEvent Class Referencefinal

#include <waitable_event.h>

Public Member Functions

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

Detailed Description

Definition at line 28 of file waitable_event.h.

Constructor & Destructor Documentation

◆ AutoResetWaitableEvent()

fml::AutoResetWaitableEvent::AutoResetWaitableEvent ( )
inline

Definition at line 30 of file waitable_event.h.

30 {}

◆ ~AutoResetWaitableEvent()

fml::AutoResetWaitableEvent::~AutoResetWaitableEvent ( )
inline

Definition at line 31 of file waitable_event.h.

References IsSignaledForTest(), Reset(), Signal(), Wait(), and WaitWithTimeout().

31 {}

Member Function Documentation

◆ IsSignaledForTest()

bool fml::AutoResetWaitableEvent::IsSignaledForTest ( )

Definition at line 120 of file waitable_event.cc.

Referenced by flutter::testing::TEST_F(), ~AutoResetWaitableEvent(), and fml::ManualResetWaitableEvent::~ManualResetWaitableEvent().

120  {
121  std::scoped_lock locker(mutex_);
122  return signaled_;
123 }

◆ Reset()

void fml::AutoResetWaitableEvent::Reset ( )

Definition at line 67 of file waitable_event.cc.

Referenced by flutter::testing::ShellTest::PumpOneFrame(), flutter::testing::TEST_F(), ~AutoResetWaitableEvent(), and fml::ManualResetWaitableEvent::~ManualResetWaitableEvent().

67  {
68  std::scoped_lock locker(mutex_);
69  signaled_ = false;
70 }

◆ Signal()

void fml::AutoResetWaitableEvent::Signal ( )

Definition at line 61 of file waitable_event.cc.

Referenced by flutter_runner::Application::Create(), flutter::Shell::Create(), flutter::testing::ShellTest::DestroyShell(), flutter::testing::ShellTest::DispatchPointerData(), flutter_runner::Engine::Engine(), flutter::Shell::GetDartVM(), flutter_runner::Engine::GetEngineReturnCode(), flutter::testing::GetRasterizerResourceCacheBytesSync(), flutter::HandleMessageOnHandler(), flutter::PlatformViewAndroid::NotifyChanged(), flutter::PlatformViewAndroid::NotifyCreated(), flutter::PlatformViewAndroid::NotifyDestroyed(), flutter::testing::ShellTest::NotifyIdle(), flutter::PlatformViewAndroid::NotifySurfaceWindowChanged(), flutter::testing::ImageDisposeTest::picture_finalizer(), flutter::testing::ShellTest::PlatformViewNotifyCreated(), flutter::testing::ShellTest::PlatformViewNotifyDestroyed(), flutter::testing::ShellTest::PumpOneFrame(), flutter::testing::RunCoroutineWithRetry(), flutter::testing::RunDartCodeInIsolate(), flutter::testing::AutoIsolateShutdown::RunInIsolateScope(), flutter::RunTester(), flutter::Shell::Screenshot(), flutter::testing::ShellTest::SetViewportMetrics(), flutter::testing::DartIsolateTest::Signal(), flutter::StartupAndShutdownShell(), fml::testing::TEST(), TEST(), flutter_runner_test::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TestSimulatedInputEvents(), flutter::testing::ValidateShell(), flutter::testing::ShellTest::VSyncFlush(), flutter::testing::AutoIsolateShutdown::~AutoIsolateShutdown(), ~AutoResetWaitableEvent(), fml::ManualResetWaitableEvent::~ManualResetWaitableEvent(), flutter_runner::Runner::~Runner(), flutter::Shell::~Shell(), flutter::testing::TestIOManager::~TestIOManager(), and flutter_runner::VsyncWaiter::~VsyncWaiter().

61  {
62  std::scoped_lock locker(mutex_);
63  signaled_ = true;
64  cv_.notify_one();
65 }

◆ Wait()

void fml::AutoResetWaitableEvent::Wait ( )

Definition at line 72 of file waitable_event.cc.

Referenced by flutter_runner::Application::Create(), flutter::Shell::Create(), flutter::testing::ShellTest::DestroyShell(), flutter::testing::ShellTest::DispatchPointerData(), flutter_runner::Engine::Engine(), flutter::Shell::GetDartVM(), flutter_runner::Engine::GetEngineReturnCode(), flutter::testing::GetRasterizerResourceCacheBytesSync(), flutter::HandleMessageOnHandler(), flutter::PlatformViewAndroid::NotifyChanged(), flutter::PlatformViewAndroid::NotifyCreated(), flutter::PlatformViewAndroid::NotifyDestroyed(), flutter::PlatformViewAndroid::NotifySurfaceWindowChanged(), flutter::testing::ShellTest::PlatformViewNotifyCreated(), flutter::testing::ShellTest::PlatformViewNotifyDestroyed(), flutter::testing::ShellTest::PumpOneFrame(), flutter::testing::RunCoroutineWithRetry(), flutter::testing::RunDartCodeInIsolate(), flutter::testing::AutoIsolateShutdown::RunInIsolateScope(), flutter::RunTester(), flutter::Shell::Screenshot(), flutter::StartupAndShutdownShell(), fml::testing::TEST(), TEST(), flutter::testing::TEST_F(), flutter::testing::TestSimulatedInputEvents(), flutter::testing::ValidateShell(), flutter::testing::ShellTest::VSyncFlush(), flutter::testing::DartIsolateTest::Wait(), flutter::testing::AutoIsolateShutdown::~AutoIsolateShutdown(), ~AutoResetWaitableEvent(), fml::ManualResetWaitableEvent::~ManualResetWaitableEvent(), flutter_runner::Runner::~Runner(), flutter::Shell::~Shell(), flutter::testing::TestIOManager::~TestIOManager(), and flutter_runner::VsyncWaiter::~VsyncWaiter().

72  {
73  std::unique_lock<std::mutex> locker(mutex_);
74  while (!signaled_) {
75  cv_.wait(locker);
76  }
77  signaled_ = false;
78 }

◆ WaitWithTimeout()

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

Definition at line 80 of file waitable_event.cc.

References FML_DCHECK, fml::TimePoint::Now(), and fml::TimeDelta::ToNanoseconds().

Referenced by flutter_runner_test::TEST_F(), flutter::testing::ShellTest::VSyncFlush(), ~AutoResetWaitableEvent(), and fml::ManualResetWaitableEvent::~ManualResetWaitableEvent().

80  {
81  std::unique_lock<std::mutex> locker(mutex_);
82 
83  if (signaled_) {
84  signaled_ = false;
85  return false;
86  }
87 
88  // We may get spurious wakeups.
89  TimeDelta wait_remaining = timeout;
90  TimePoint start = TimePoint::Now();
91  while (true) {
92  if (std::cv_status::timeout ==
93  cv_.wait_for(
94  locker, std::chrono::nanoseconds(wait_remaining.ToNanoseconds()))) {
95  return true; // Definitely timed out.
96  }
97 
98  // We may have been awoken.
99  if (signaled_) {
100  break;
101  }
102 
103  // Or the wakeup may have been spurious.
104  TimePoint now = TimePoint::Now();
105  FML_DCHECK(now >= start);
106  TimeDelta elapsed = now - start;
107  // It's possible that we may have timed out anyway.
108  if (elapsed >= timeout) {
109  return true;
110  }
111 
112  // Otherwise, recalculate the amount that we have left to wait.
113  wait_remaining = timeout - elapsed;
114  }
115 
116  signaled_ = false;
117  return false;
118 }
#define FML_DCHECK(condition)
Definition: logging.h:86
static TimePoint Now()
Definition: time_point.cc:26

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