未验证 提交 663b4925 编写于 作者: J Joshua Seaton 提交者: GitHub

[fml][fxl] Migrate AutoResetWaitableEvent to fml version. (#5808)

Thanks Jason for the speedy review
上级 4e55ff9a
......@@ -7,7 +7,8 @@
#include <map>
#include "lib/fxl/synchronization/waitable_event.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "lib/fxl/macros.h"
#include "third_party/skia/include/core/SkCanvas.h"
namespace flow {
......
......@@ -7,9 +7,9 @@
#include <thread>
#include "flutter/fml/message_loop.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/task_runner.h"
#include "gtest/gtest.h"
#include "lib/fxl/synchronization/waitable_event.h"
#define TIME_SENSITIVE(x) TimeSensitiveTest_##x
#if OS_WIN
......@@ -28,8 +28,8 @@ TEST(MessageLoop, GetCurrent) {
TEST(MessageLoop, DifferentThreadsHaveDifferentLoops) {
fml::MessageLoop* loop1 = nullptr;
fxl::AutoResetWaitableEvent latch1;
fxl::AutoResetWaitableEvent term1;
fml::AutoResetWaitableEvent latch1;
fml::AutoResetWaitableEvent term1;
std::thread thread1([&loop1, &latch1, &term1]() {
fml::MessageLoop::EnsureInitializedForCurrentThread();
loop1 = &fml::MessageLoop::GetCurrent();
......@@ -38,8 +38,8 @@ TEST(MessageLoop, DifferentThreadsHaveDifferentLoops) {
});
fml::MessageLoop* loop2 = nullptr;
fxl::AutoResetWaitableEvent latch2;
fxl::AutoResetWaitableEvent term2;
fml::AutoResetWaitableEvent latch2;
fml::AutoResetWaitableEvent term2;
std::thread thread2([&loop2, &latch2, &term2]() {
fml::MessageLoop::EnsureInitializedForCurrentThread();
loop2 = &fml::MessageLoop::GetCurrent();
......@@ -135,7 +135,7 @@ TEST(MessageLoop, DelayedTasksAtSameTimeAreRunInOrder) {
TEST(MessageLoop, CheckRunsTaskOnCurrentThread) {
fxl::RefPtr<fxl::TaskRunner> runner;
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
std::thread thread([&runner, &latch]() {
fml::MessageLoop::EnsureInitializedForCurrentThread();
auto& loop = fml::MessageLoop::GetCurrent();
......
......@@ -18,12 +18,12 @@
#include <string>
#include "flutter/fml/message_loop.h"
#include "lib/fxl/synchronization/waitable_event.h"
#include "flutter/fml/synchronization/waitable_event.h"
namespace fml {
Thread::Thread(const std::string& name) : joined_(false) {
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
fxl::RefPtr<fml::TaskRunner> runner;
thread_ = std::make_unique<std::thread>([&latch, &runner, name]() -> void {
SetCurrentThreadName(name);
......
......@@ -13,7 +13,7 @@
#include <utility>
#include <vector>
#include "lib/fxl/synchronization/waitable_event.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "third_party/dart/runtime/include/dart_tools_api.h"
......@@ -138,7 +138,7 @@ static bool HandleMessageOnHandler(
const ServiceProtocol::Handler::ServiceProtocolMap& params,
rapidjson::Document& document) {
FXL_DCHECK(handler);
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
bool result = false;
fml::TaskRunner::RunNowOrPostTask(
handler->GetServiceProtocolHandlerTaskRunner(method),
......@@ -240,7 +240,7 @@ bool ServiceProtocol::HandleListViewsMethod(
std::lock_guard<std::mutex> lock(handlers_mutex_);
std::vector<std::pair<intptr_t, Handler::Description>> descriptions;
for (const auto& handler : handlers_) {
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
Handler::Description description;
fml::TaskRunner::RunNowOrPostTask(
......
......@@ -6,11 +6,11 @@
#include <utility>
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/vsync_waiter_fallback.h"
#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/synchronization/waitable_event.h"
#include "third_party/skia/include/gpu/GrContextOptions.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
......
......@@ -11,10 +11,10 @@
#include "flutter/flow/compositor_context.h"
#include "flutter/flow/layers/layer_tree.h"
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/shell/common/surface.h"
#include "flutter/synchronization/pipeline.h"
#include "lib/fxl/functional/closure.h"
#include "lib/fxl/synchronization/waitable_event.h"
namespace shell {
......
......@@ -67,7 +67,7 @@ std::unique_ptr<Shell> Shell::CreateShellOnPlatformThread(
// first because it has state that the other subsystems depend on. It must
// first be booted and the necessary references obtained to initialize the
// other subsystems.
fxl::AutoResetWaitableEvent io_latch;
fml::AutoResetWaitableEvent io_latch;
std::unique_ptr<IOManager> io_manager;
fml::WeakPtr<GrContext> resource_context;
fxl::RefPtr<flow::SkiaUnrefQueue> unref_queue;
......@@ -90,7 +90,7 @@ std::unique_ptr<Shell> Shell::CreateShellOnPlatformThread(
io_latch.Wait();
// Create the rasterizer on the GPU thread.
fxl::AutoResetWaitableEvent gpu_latch;
fml::AutoResetWaitableEvent gpu_latch;
std::unique_ptr<Rasterizer> rasterizer;
fml::TaskRunner::RunNowOrPostTask(
task_runners.GetGPUTaskRunner(), [&gpu_latch, //
......@@ -105,7 +105,7 @@ std::unique_ptr<Shell> Shell::CreateShellOnPlatformThread(
});
// Create the engine on the UI thread.
fxl::AutoResetWaitableEvent ui_latch;
fml::AutoResetWaitableEvent ui_latch;
std::unique_ptr<Engine> engine;
fml::TaskRunner::RunNowOrPostTask(
shell->GetTaskRunners().GetUITaskRunner(),
......@@ -237,7 +237,7 @@ std::unique_ptr<Shell> Shell::Create(
return nullptr;
}
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
std::unique_ptr<Shell> shell;
fml::TaskRunner::RunNowOrPostTask(
task_runners.GetPlatformTaskRunner(),
......@@ -304,7 +304,7 @@ Shell::~Shell() {
vm->GetServiceProtocol().RemoveHandler(this);
}
fxl::AutoResetWaitableEvent ui_latch, gpu_latch, platform_latch, io_latch;
fml::AutoResetWaitableEvent ui_latch, gpu_latch, platform_latch, io_latch;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetUITaskRunner(),
......@@ -415,7 +415,7 @@ void Shell::OnPlatformViewCreated(const PlatformView& view,
// setup/suspension of all activities that may be interacting with the GPU in
// a synchronous fashion.
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
auto gpu_task = fxl::MakeCopyable([rasterizer = rasterizer_->GetWeakPtr(), //
surface = std::move(surface), //
&latch]() mutable {
......@@ -456,7 +456,7 @@ void Shell::OnPlatformViewDestroyed(const PlatformView& view) {
// setup/suspension of all activities that may be interacting with the GPU in
// a synchronous fashion.
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
auto io_task = [io_manager = io_manager_.get(), &latch]() {
// Execute any pending Skia object deletions while GPU access is still
......@@ -974,7 +974,7 @@ Rasterizer::Screenshot Shell::Screenshot(
Rasterizer::ScreenshotType screenshot_type,
bool base64_encode) {
TRACE_EVENT0("flutter", "Shell::Screenshot");
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
Rasterizer::Screenshot screenshot;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetGPUTaskRunner(), [&latch, //
......
......@@ -13,6 +13,7 @@
#include "flutter/flow/texture.h"
#include "flutter/fml/memory/thread_checker.h"
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/thread.h"
#include "flutter/lib/ui/semantics/custom_accessibility_action.h"
#include "flutter/lib/ui/semantics/semantics_node.h"
......@@ -31,7 +32,6 @@
#include "lib/fxl/strings/string_view.h"
#include "lib/fxl/synchronization/thread_annotations.h"
#include "lib/fxl/synchronization/thread_checker.h"
#include "lib/fxl/synchronization/waitable_event.h"
namespace shell {
......
......@@ -9,12 +9,12 @@
#include <memory>
#include "flutter/fml/message_loop.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/thread_host.h"
#include "gtest/gtest.h"
#include "lib/fxl/synchronization/waitable_event.h"
#define CURRENT_TEST_NAME \
std::string { \
......
......@@ -7,13 +7,13 @@
#include <memory>
#include <utility>
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/shell/common/io_manager.h"
#include "flutter/shell/platform/android/android_external_texture_gl.h"
#include "flutter/shell/platform/android/android_surface_gl.h"
#include "flutter/shell/platform/android/platform_message_response_android.h"
#include "flutter/shell/platform/android/platform_view_android_jni.h"
#include "flutter/shell/platform/android/vsync_waiter_android.h"
#include "lib/fxl/synchronization/waitable_event.h"
namespace shell {
......@@ -45,7 +45,7 @@ void PlatformViewAndroid::NotifyDestroyed() {
}
void PlatformViewAndroid::NotifyChanged(const SkISize& size) {
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
fml::TaskRunner::RunNowOrPostTask(
task_runners_.GetGPUTaskRunner(), //
[&latch, surface = android_surface_.get(), size]() {
......
......@@ -7,13 +7,13 @@
#include <AppKit/AppKit.h>
#include <Foundation/Foundation.h>
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/io_manager.h"
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/switches.h"
#include "flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h"
#include "lib/fxl/command_line.h"
#include "lib/fxl/synchronization/waitable_event.h"
namespace shell {
......
......@@ -8,6 +8,7 @@
#include "flutter/common/task_runners.h"
#include "flutter/flow/layers/layer_tree.h"
#include "flutter/fml/platform/darwin/cf_utils.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/rasterizer.h"
......@@ -15,7 +16,6 @@
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
#include "flutter/shell/platform/darwin/ios/ios_surface_gl.h"
#include "flutter/shell/platform/darwin/ios/ios_surface_software.h"
#include "lib/fxl/synchronization/waitable_event.h"
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
@interface FlutterView () <UIInputViewAudioFeedback>
......
......@@ -9,11 +9,11 @@
#include <utility>
#include "flutter/common/task_runners.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/io_manager.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h"
#include "flutter/shell/platform/darwin/ios/ios_external_texture_gl.h"
#include "lib/fxl/synchronization/waitable_event.h"
namespace shell {
......
......@@ -11,6 +11,7 @@
#include "flutter/fml/file.h"
#include "flutter/fml/message_loop.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/task_runner.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/rasterizer.h"
......@@ -19,7 +20,6 @@
#include "flutter/shell/common/thread_host.h"
#include "lib/fxl/files/path.h"
#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/synchronization/waitable_event.h"
#include "third_party/dart/runtime/bin/embedded_dart_io.h"
#ifdef ERROR
......@@ -177,7 +177,7 @@ int RunTester(const blink::Settings& settings, bool run_forever) {
bool engine_did_run = false;
fxl::AutoResetWaitableEvent sync_run_latch;
fml::AutoResetWaitableEvent sync_run_latch;
fml::TaskRunner::RunNowOrPostTask(
shell->GetTaskRunners().GetUITaskRunner(),
fxl::MakeCopyable([&sync_run_latch, &completion_observer,
......@@ -208,7 +208,7 @@ int RunTester(const blink::Settings& settings, bool run_forever) {
// Cleanup the completion observer synchronously as it is living on the
// stack.
fxl::AutoResetWaitableEvent latch;
fml::AutoResetWaitableEvent latch;
fml::TaskRunner::RunNowOrPostTask(
shell->GetTaskRunners().GetUITaskRunner(),
[&latch, &completion_observer] {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册