| Flutter Windows Embedder |

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

`#include <task_runner_window.h>`

## 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 ()

## Detailed Description

Definition at line 51 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 160 of file task_runner_window.cc.

160 {
161 delegates_.push_back(delegate);
162 SetTimer(std::chrono::nanoseconds::zero());
163 }

## ◆ GetSharedInstance()

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

Definition at line 131 of file task_runner_window.cc.

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

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

## ◆ PollOnce()

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

Definition at line 172 of file task_runner_window.cc.

172 {
173 MSG msg;
174 ::SetTimer(window_handle_, kPollTimeoutTimerId, timeout.count(), nullptr);
175 if (GetMessage(&msg, window_handle_, 0, 0)) {
176 TranslateMessage(&msg);
177 DispatchMessage(&msg);
178 }
179 ::KillTimer(window_handle_, kPollTimeoutTimerId);
180 }
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 165 of file task_runner_window.cc.

165 {
166 auto i = std::find(delegates_.begin(), delegates_.end(), delegate);
167 if (i != delegates_.end()) {
168 delegates_.erase(i);
169 }
170 }

## ◆ WakeUp()

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

Definition at line 142 of file task_runner_window.cc.

142 {
143 // When waking up from main thread while there are messages in the message
144 // queue use timer to post the WM_NULL message from background thread. This
145 // gives message loop chance to process input events before WM_NULL is
146 // processed - which is necessary because messages scheduled through
147 // PostMessage take precedence over input event messages. Otherwise await
148 // Future.delayed(Duration.zero) deadlocks the main thread. (See
149 // https://github.com/flutter/flutter/issues/173843)
150 if (thread_id_ == GetCurrentThreadId() && GetQueueStatus(QS_ALLEVENTS) != 0) {
151 SetTimer(std::chrono::milliseconds(1));
152 return;
153 }
154
155 if (!PostMessage(window_handle_, WM_NULL, 0, 0)) {
156 FML_LOG(ERROR) << "Failed to post message to main thread.";
157 }
158 }

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