mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_WINRT_TASK_RUNNER_H_
|
|
#define FLUTTER_SHELL_PLATFORM_WINDOWS_WINRT_TASK_RUNNER_H_
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winrt/Windows.UI.Core.h>
|
|
|
|
#include <chrono>
|
|
#include <functional>
|
|
#include <thread>
|
|
|
|
#include "flutter/shell/platform/embedder/embedder.h"
|
|
#include "flutter/shell/platform/windows/task_runner.h"
|
|
|
|
namespace flutter {
|
|
|
|
// A custom task runner that uses a CoreDispatcher to schedule
|
|
// flutter tasks.
|
|
class TaskRunnerWinUwp : public TaskRunner {
|
|
public:
|
|
TaskRunnerWinUwp(DWORD main_thread_id,
|
|
const TaskExpiredCallback& on_task_expired);
|
|
|
|
~TaskRunnerWinUwp();
|
|
|
|
TaskRunnerWinUwp(const TaskRunnerWinUwp&) = delete;
|
|
TaskRunnerWinUwp& operator=(const TaskRunnerWinUwp&) = delete;
|
|
|
|
// |TaskRunner|
|
|
bool RunsTasksOnCurrentThread() const override;
|
|
|
|
// |TaskRunner|
|
|
void PostTask(FlutterTask flutter_task,
|
|
uint64_t flutter_target_time_nanos) override;
|
|
|
|
private:
|
|
DWORD main_thread_id_;
|
|
TaskExpiredCallback on_task_expired_;
|
|
|
|
winrt::Windows::UI::Core::CoreDispatcher dispatcher_{nullptr};
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINRT_TASK_RUNNER_H_
|