Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
event_watcher.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/shell/platform/windows/event_watcher.h"
6
7namespace flutter {
8
9EventWatcher::EventWatcher(std::function<void()> callback)
10 : callback_(callback) {
11 handle_ = CreateEvent(NULL, TRUE, FALSE, NULL);
12
13 RegisterWaitForSingleObject(&handle_for_wait_, handle_, &CallbackForWait,
14 reinterpret_cast<void*>(this), INFINITE,
15 WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD);
16}
17
19 UnregisterWait(handle_for_wait_);
20 CloseHandle(handle_);
21}
22
24 return handle_;
25}
26
27// static
28VOID CALLBACK EventWatcher::CallbackForWait(PVOID context, BOOLEAN) {
29 EventWatcher* self = reinterpret_cast<EventWatcher*>(context);
30 ResetEvent(self->handle_);
31 self->callback_();
32}
33
34} // namespace flutter
EventWatcher(std::function< void()> callback)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
return FALSE
void * PVOID
BYTE BOOLEAN
#define CreateEvent
#define VOID
void * HANDLE
#define CALLBACK