summaryrefslogtreecommitdiff
path: root/src/node_platform.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-03-14 20:24:41 +0100
committerJames M Snell <jasnell@gmail.com>2020-03-20 17:50:35 -0700
commitd129e0c782914df8720d1335c95bd7f635f2788e (patch)
tree093746c065dd09ca0148fe0ec967fa3558f938de /src/node_platform.cc
parent064a6703a720f669f868e35cca69412ee3f962c5 (diff)
downloadnode-new-d129e0c782914df8720d1335c95bd7f635f2788e.tar.gz
src: avoid Isolate::GetCurrent() for platform implementation
There’s no need to use `Isolate::GetCurrent()`, which is generally discouraged, as the `Isolate*` pointer can generally be looked up from the per-Isolate platform data structure. PR-URL: https://github.com/nodejs/node/pull/32269 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_platform.cc')
-rw-r--r--src/node_platform.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/node_platform.cc b/src/node_platform.cc
index 713051efc3..740ace1fb7 100644
--- a/src/node_platform.cc
+++ b/src/node_platform.cc
@@ -222,7 +222,7 @@ int WorkerThreadsTaskRunner::NumberOfWorkerThreads() const {
PerIsolatePlatformData::PerIsolatePlatformData(
Isolate* isolate, uv_loop_t* loop)
- : loop_(loop) {
+ : isolate_(isolate), loop_(loop) {
flush_tasks_ = new uv_async_t();
CHECK_EQ(0, uv_async_init(loop, flush_tasks_, FlushTasks));
flush_tasks_->data = static_cast<void*>(this);
@@ -391,12 +391,11 @@ int NodePlatform::NumberOfWorkerThreads() {
}
void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr<Task> task) {
- Isolate* isolate = Isolate::GetCurrent();
- DebugSealHandleScope scope(isolate);
- Environment* env = Environment::GetCurrent(isolate);
+ DebugSealHandleScope scope(isolate_);
+ Environment* env = Environment::GetCurrent(isolate_);
if (env != nullptr) {
- v8::HandleScope scope(isolate);
- InternalCallbackScope cb_scope(env, Object::New(isolate), { 0, 0 },
+ v8::HandleScope scope(isolate_);
+ InternalCallbackScope cb_scope(env, Object::New(isolate_), { 0, 0 },
InternalCallbackScope::kNoFlags);
task->Run();
} else {
@@ -415,8 +414,8 @@ void PerIsolatePlatformData::DeleteFromScheduledTasks(DelayedTask* task) {
}
void PerIsolatePlatformData::RunForegroundTask(uv_timer_t* handle) {
- DelayedTask* delayed = static_cast<DelayedTask*>(handle->data);
- RunForegroundTask(std::move(delayed->task));
+ DelayedTask* delayed = ContainerOf(&DelayedTask::timer, handle);
+ delayed->platform_data->RunForegroundTask(std::move(delayed->task));
delayed->platform_data->DeleteFromScheduledTasks(delayed);
}