-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: implement v8::Platform::CallDelayedOnWorkerThread #22383
Conversation
src/node_platform.cc
Outdated
std::unique_ptr<Task> TakeTimerTask(uv_timer_t* timer) { | ||
std::unique_ptr<Task> task(static_cast<Task*>(timer->data)); | ||
uv_timer_stop(timer); | ||
uv_close(reinterpret_cast<uv_handle_t*>(timer), [](uv_handle_t* handle) {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn’t the close callback free the memory allocated for handle
here? Or, alternatively …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we should, fixed.
src/node_platform.cc
Outdated
TaskQueue<v8::Task> tasks_; | ||
uv_loop_t loop_; | ||
uv_async_t flush_tasks_; | ||
std::set<uv_timer_t*> timers_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… I think we could use the fact that std::set
comes with retaining referential integrity in the presence of insert/erase operations, so we could avoid the double allocations and use std::set<uv_timer_t>
instead, right? (If not: I don’t think there’s an advantage over std::unordered_set
, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit allocation looks simpler to me, so I replaced set with unordered_set. Thank you!
src/node_platform.cc
Outdated
|
||
static void RunTask(uv_timer_t* timer) { | ||
DelayedTaskScheduler* scheduler = | ||
static_cast<DelayedTaskScheduler*>(timer->loop->data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: scheduler = ContainerOf(&DelayedTaskScheduler::loop_, timer->loop);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
This PR needs a rebase against master to avoid the git failure in the CI. |
I rebased and restarted CI: https://ci.nodejs.org/job/node-test-pull-request/16589/ |
This method is crucial for Runtime.evaluate protocol command with timeout flag. At least Chrome DevTools frontend uses this method for every execution in console. Fixes: #22157
Landed in b1e2612 |
This method is crucial for Runtime.evaluate protocol command with timeout flag. At least Chrome DevTools frontend uses this method for every execution in console. PR-URL: #22383 Fixes: #22157 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
I uploaded rebased PR and started CI there, I won't have internet connection next 12 hours, so I would appreciate help with merging my backport, thanks ahead! |
This method is crucial for Runtime.evaluate protocol command with timeout flag. At least Chrome DevTools frontend uses this method for every execution in console. Backport-PR-URL: #22567 PR-URL: #22383 Fixes: #22157 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This method is crucial for Runtime.evaluate protocol command with timeout flag. At least Chrome DevTools frontend uses this method for every execution in console. Backport-PR-URL: #22567 PR-URL: #22383 Fixes: #22157 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This method is crucial for Runtime.evaluate protocol command with timeout flag. At least Chrome DevTools frontend uses this method for every execution in console. Backport-PR-URL: #22567 PR-URL: #22383 Fixes: #22157 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This method is crucial for Runtime.evaluate protocol command with timeout flag. At least Chrome DevTools frontend uses this method for every execution in console. PR-URL: nodejs#22383 Fixes: nodejs#22157 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This method is crucial for Runtime.evaluate protocol command with
timeout flag. At least Chrome DevTools frontend uses this flag for
every execution in console.
Fixes: #22157
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes