| Flutter Windows Embedder |

Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
flutter::TaskRunnerWindow Class Reference

`#include <task_runner_window.h>`

Inheritance diagram for flutter::TaskRunnerWindow:

## Classes
class | Delegate

## Public Member Functions
void | WakeUp ()
void | AddDelegate (Delegate *delegate)
void | RemoveDelegate (Delegate *delegate)
void | PollOnce (std::chrono::milliseconds timeout)
| ~TaskRunnerWindow ()

## Static Public Member Functions
static std::shared_ptr< TaskRunnerWindow > | GetSharedInstance ()

## Friends
class | testing::TestTaskRunnerWindow

## Detailed Description

Definition at line 56 of file task_runner_window.h.

## Constructor & Destructor Documentation

## ◆ ~TaskRunnerWindow()

flutter::TaskRunnerWindow::~TaskRunnerWindow | ( |  | ) |

Definition at line 109 of file task_runner_window.cc.

109 {
110 timer_thread_.Stop();
111
112 if (window_handle_) {
113 DestroyWindow(window_handle_);
114 window_handle_ = nullptr;
115 }
116 UnregisterClass(window_class_name_.c_str(), nullptr);
117 }
flutter::TimerThread::Stop
void Stop()
Definition: task_runner_window.cc:29

## Member Function Documentation

## ◆ AddDelegate()

void flutter::TaskRunnerWindow::AddDelegate | ( | Delegate * | delegate | ) |

Definition at line 152 of file task_runner_window.cc.

152 {
153 delegates_.push_back(delegate);
154 SetTimer(std::chrono::nanoseconds::zero());
155 }

Referenced by flutter::testing::TEST().

## ◆ GetSharedInstance()

std::shared_ptr< TaskRunnerWindow > flutter::TaskRunnerWindow::GetSharedInstance | ( |  | ) |
| static

Definition at line 129 of file task_runner_window.cc.

129 {
130 static std::weak_ptr<TaskRunnerWindow> instance;
131 auto res = instance.lock();
132 if (!res) {
133 // can't use make_shared with private contructor
134 res.reset(new TaskRunnerWindow());
135 instance = res;
136 }
137 return res;
138 }

Referenced by flutter::TaskRunner::TaskRunner().

## ◆ PollOnce()

void flutter::TaskRunnerWindow::PollOnce | ( | std::chrono::milliseconds | timeout | ) |

Definition at line 164 of file task_runner_window.cc.

164 {
165 MSG msg;
166 ::SetTimer(window_handle_, kPollTimeoutTimerId, timeout.count(), nullptr);
167 if (GetMessage(&msg, window_handle_, 0, 0)) {
168 TranslateMessage(&msg);
169 DispatchMessage(&msg);
170 }
171 ::KillTimer(window_handle_, kPollTimeoutTimerId);
172 }
flutter::kPollTimeoutTimerId
static const uintptr_t kPollTimeoutTimerId
Definition: task_runner_window.cc:82

References flutter::kPollTimeoutTimerId.

## ◆ RemoveDelegate()

void flutter::TaskRunnerWindow::RemoveDelegate | ( | Delegate * | delegate | ) |

Definition at line 157 of file task_runner_window.cc.

157 {
158 auto i = std::find(delegates_.begin(), delegates_.end(), delegate);
159 if (i != delegates_.end()) {
160 delegates_.erase(i);
161 }
162 }

## ◆ WakeUp()

void flutter::TaskRunnerWindow::WakeUp | ( |  | ) |

Definition at line 140 of file task_runner_window.cc.

140 {
141 bool expected = false;
142 // Only post wake up message if needed otherwise the message queue will
143 // get flooded possibly resulting in application stopping to respond.
144 // https://github.com/flutter/flutter/issues/173843
145 if (wake_up_posted_.compare_exchange_strong(expected, true)) {
146 if (!PostMessage(window_handle_, WM_NULL, 0, 0)) {
147 FML_LOG(ERROR) << "Failed to post message to main thread.";
148 }
149 }
150 }

Referenced by flutter::testing::TEST().

## Friends And Related Function Documentation

## ◆ testing::TestTaskRunnerWindow

friend class testing::TestTaskRunnerWindow
| friend

Definition at line 80 of file task_runner_window.h.

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

- shell/platform/windows/task_runner_window.h
- shell/platform/windows/task_runner_window.cc