From 2c640bfa46a2fdc2f0e9e88c0377759fa82d9f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 25 May 2019 18:07:32 +0200 Subject: [PATCH] src: unimplement deprecated v8-platform methods This removes the implementations of NodePlatform::CallOnForegroundThread and NodePlatform::CallDelayedOnForegroundThread and updates the test_platform cctest to stop using them. PR-URL: https://github.com/nodejs/node/pull/27872 Reviewed-By: Gus Caplan Reviewed-By: Refael Ackermann Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- src/node_platform.cc | 11 ----------- src/node_platform.h | 11 ++++++++--- test/cctest/test_platform.cc | 12 ++++++++---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/node_platform.cc b/src/node_platform.cc index 406146b841e25e..b2e8d77ec7a987 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -445,17 +445,6 @@ NodePlatform::ForIsolate(Isolate* isolate) { return data; } -void NodePlatform::CallOnForegroundThread(Isolate* isolate, Task* task) { - ForIsolate(isolate)->PostTask(std::unique_ptr(task)); -} - -void NodePlatform::CallDelayedOnForegroundThread(Isolate* isolate, - Task* task, - double delay_in_seconds) { - ForIsolate(isolate)->PostDelayedTask( - std::unique_ptr(task), delay_in_seconds); -} - bool NodePlatform::FlushForegroundTasks(Isolate* isolate) { return ForIsolate(isolate)->FlushForegroundTasksInternal(); } diff --git a/src/node_platform.h b/src/node_platform.h index 66f86cfa7e74d5..d2eb325c12113e 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -145,9 +145,14 @@ class NodePlatform : public MultiIsolatePlatform { void CallOnWorkerThread(std::unique_ptr task) override; void CallDelayedOnWorkerThread(std::unique_ptr task, double delay_in_seconds) override; - void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) override; - void CallDelayedOnForegroundThread(v8::Isolate* isolate, v8::Task* task, - double delay_in_seconds) override; + void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) override { + UNREACHABLE(); + } + void CallDelayedOnForegroundThread(v8::Isolate* isolate, + v8::Task* task, + double delay_in_seconds) override { + UNREACHABLE(); + } bool IdleTasksEnabled(v8::Isolate* isolate) override; double MonotonicallyIncreasingTime() override; double CurrentClockTimeMillis() override; diff --git a/test/cctest/test_platform.cc b/test/cctest/test_platform.cc index 876547480b7032..5420502124d6da 100644 --- a/test/cctest/test_platform.cc +++ b/test/cctest/test_platform.cc @@ -23,8 +23,10 @@ class RepostingTask : public v8::Task { ++*run_count_; if (repost_count_ > 0) { --repost_count_; - platform_->CallOnForegroundThread(isolate_, - new RepostingTask(repost_count_, run_count_, isolate_, platform_)); + std::shared_ptr task_runner = + platform_->GetForegroundTaskRunner(isolate_); + task_runner->PostTask(std::make_unique( + repost_count_, run_count_, isolate_, platform_)); } } @@ -43,8 +45,10 @@ TEST_F(PlatformTest, SkipNewTasksInFlushForegroundTasks) { const Argv argv; Env env {handle_scope, argv}; int run_count = 0; - platform->CallOnForegroundThread( - isolate_, new RepostingTask(2, &run_count, isolate_, platform.get())); + std::shared_ptr task_runner = + platform->GetForegroundTaskRunner(isolate_); + task_runner->PostTask( + std::make_unique(2, &run_count, isolate_, platform.get())); EXPECT_TRUE(platform->FlushForegroundTasks(isolate_)); EXPECT_EQ(1, run_count); EXPECT_TRUE(platform->FlushForegroundTasks(isolate_));