mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Currently, all Flutter threads are managed by the engine itself. This works for all threads except the platform thread. On this thread, the engine cannot see the underlying event multiplexing mechanism. Using the new task runner interfaces, the engine can relinquish the task of setting up the event multiplexing mechanism and instead have the embedder provide one for it during setup. This scheme is only wired up for the platform thread. But, the eventual goal is to expose this message loop interoperability for all threads.
55 lines
1.6 KiB
C++
55 lines
1.6 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_EMBEDDER_EMBEDDER_THREAD_HOST_H_
|
|
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_THREAD_HOST_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
|
|
#include "flutter/common/task_runners.h"
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/shell/common/thread_host.h"
|
|
#include "flutter/shell/platform/embedder/embedder.h"
|
|
#include "flutter/shell/platform/embedder/embedder_task_runner.h"
|
|
|
|
namespace shell {
|
|
|
|
class EmbedderThreadHost {
|
|
public:
|
|
static std::unique_ptr<EmbedderThreadHost>
|
|
CreateEmbedderOrEngineManagedThreadHost(
|
|
const FlutterCustomTaskRunners* custom_task_runners);
|
|
|
|
EmbedderThreadHost(
|
|
ThreadHost host,
|
|
blink::TaskRunners runners,
|
|
std::set<fml::RefPtr<EmbedderTaskRunner>> embedder_task_runners);
|
|
|
|
~EmbedderThreadHost();
|
|
|
|
bool IsValid() const;
|
|
|
|
const blink::TaskRunners& GetTaskRunners() const;
|
|
|
|
bool PostTask(int64_t runner, uint64_t task) const;
|
|
|
|
private:
|
|
ThreadHost host_;
|
|
blink::TaskRunners runners_;
|
|
std::map<int64_t, fml::RefPtr<EmbedderTaskRunner>> runners_map_;
|
|
|
|
static std::unique_ptr<EmbedderThreadHost> CreateEmbedderManagedThreadHost(
|
|
const FlutterCustomTaskRunners* custom_task_runners);
|
|
|
|
static std::unique_ptr<EmbedderThreadHost> CreateEngineManagedThreadHost();
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderThreadHost);
|
|
};
|
|
|
|
} // namespace shell
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_THREAD_HOST_H_
|