mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This issue would only manifest when a custom task runner was being used with a custom compositor. Both were tested separately but not together. A new test has been added for this. We still create the GPU thread merger unnecessarily but I can patch that later. I also cleaned up the existing custom task runner test to not submit tasks on a dead engine as they just log errors unnecessarily. Filed new: https://github.com/flutter/flutter/issues/38844
62 lines
1.7 KiB
C++
62 lines
1.7 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_TASK_RUNNER_H_
|
|
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_TASK_RUNNER_H_
|
|
|
|
#include <mutex>
|
|
#include <unordered_map>
|
|
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/fml/synchronization/thread_annotations.h"
|
|
#include "flutter/fml/task_runner.h"
|
|
|
|
namespace flutter {
|
|
|
|
class EmbedderTaskRunner final : public fml::TaskRunner {
|
|
public:
|
|
struct DispatchTable {
|
|
std::function<void(EmbedderTaskRunner* task_runner,
|
|
uint64_t task_baton,
|
|
fml::TimePoint target_time)>
|
|
post_task_callback;
|
|
std::function<bool(void)> runs_task_on_current_thread_callback;
|
|
};
|
|
|
|
EmbedderTaskRunner(DispatchTable table);
|
|
|
|
~EmbedderTaskRunner() override;
|
|
|
|
bool PostTask(uint64_t baton);
|
|
|
|
// |fml::TaskRunner|
|
|
void PostTask(fml::closure task) override;
|
|
|
|
// |fml::TaskRunner|
|
|
void PostTaskForTime(fml::closure task, fml::TimePoint target_time) override;
|
|
|
|
// |fml::TaskRunner|
|
|
void PostDelayedTask(fml::closure task, fml::TimeDelta delay) override;
|
|
|
|
// |fml::TaskRunner|
|
|
bool RunsTasksOnCurrentThread() override;
|
|
|
|
// |fml::TaskRunner|
|
|
fml::TaskQueueId GetTaskQueueId() override;
|
|
|
|
private:
|
|
DispatchTable dispatch_table_;
|
|
std::mutex tasks_mutex_;
|
|
uint64_t last_baton_ FML_GUARDED_BY(tasks_mutex_);
|
|
std::unordered_map<uint64_t, fml::closure> pending_tasks_
|
|
FML_GUARDED_BY(tasks_mutex_);
|
|
fml::TaskQueueId placeholder_id_;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTaskRunner);
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_TASK_RUNNER_H_
|