Flutter Engine
message_loop_win.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/fml/platform/win/message_loop_win.h"
6 
7 #include "flutter/fml/logging.h"
8 
9 namespace fml {
10 
11 MessageLoopWin::MessageLoopWin()
12  : timer_(CreateWaitableTimer(NULL, FALSE, NULL)) {
13  FML_CHECK(timer_.is_valid());
14 }
15 
16 MessageLoopWin::~MessageLoopWin() = default;
17 
18 void MessageLoopWin::Run() {
19  running_ = true;
20 
21  while (running_) {
22  FML_CHECK(WaitForSingleObject(timer_.get(), INFINITE) == 0);
24  }
25 }
26 
27 void MessageLoopWin::Terminate() {
28  running_ = false;
29  WakeUp(fml::TimePoint::Now());
30 }
31 
32 void MessageLoopWin::WakeUp(fml::TimePoint time_point) {
33  LARGE_INTEGER due_time = {0};
35  if (time_point > now) {
36  due_time.QuadPart = (time_point - now).ToNanoseconds() / -100;
37  }
38  FML_CHECK(SetWaitableTimer(timer_.get(), &due_time, 0, NULL, NULL, FALSE));
39 }
40 
41 } // namespace fml
const T & get() const
Definition: unique_object.h:87
Definition: ascii_trie.cc:9
#define FML_CHECK(condition)
Definition: logging.h:68
static TimePoint Now()
Definition: time_point.cc:26