src: remove use of CallOnForegroundThread()

The V8 platform's CallOnForegroundThread() method is deprecated.
This commit replaces its use with GetForegroundTaskRunner()
functionality instead.

PR-URL: https://github.com/nodejs/node/pull/24925
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig 2018-12-09 14:05:43 -05:00 committed by Rich Trott
parent 91c0a370f6
commit 40767a6070
2 changed files with 9 additions and 4 deletions

View File

@ -255,8 +255,9 @@ void MainThreadInterface::Post(std::unique_ptr<Request> request) {
if (needs_notify) {
CHECK_EQ(0, uv_async_send(&main_thread_request_->first));
if (isolate_ != nullptr && platform_ != nullptr) {
platform_->CallOnForegroundThread(isolate_,
new DispatchMessagesTask(this));
std::shared_ptr<v8::TaskRunner> taskrunner =
platform_->GetForegroundTaskRunner(isolate_);
taskrunner->PostTask(std::make_unique<DispatchMessagesTask>(this));
isolate_->RequestInterrupt([](v8::Isolate* isolate, void* thread) {
static_cast<MainThreadInterface*>(thread)->DispatchMessages();
}, this);

View File

@ -40,6 +40,8 @@ using v8::Local;
using v8::Message;
using v8::Object;
using v8::String;
using v8::Task;
using v8::TaskRunner;
using v8::Value;
using v8_inspector::StringBuffer;
@ -50,7 +52,7 @@ using v8_inspector::V8InspectorClient;
static uv_sem_t start_io_thread_semaphore;
static uv_async_t start_io_thread_async;
class StartIoTask : public v8::Task {
class StartIoTask : public Task {
public:
explicit StartIoTask(Agent* agent) : agent(agent) {}
@ -861,7 +863,9 @@ void Agent::RequestIoThreadStart() {
uv_async_send(&start_io_thread_async);
Isolate* isolate = parent_env_->isolate();
v8::Platform* platform = parent_env_->isolate_data()->platform();
platform->CallOnForegroundThread(isolate, new StartIoTask(this));
std::shared_ptr<TaskRunner> taskrunner =
platform->GetForegroundTaskRunner(isolate);
taskrunner->PostTask(std::make_unique<StartIoTask>(this));
isolate->RequestInterrupt(StartIoInterrupt, this);
uv_async_send(&start_io_thread_async);
}