Skip to content

Conversation

eugeneo
Copy link
Contributor

@eugeneo eugeneo commented Jul 18, 2017

This timer is currently only used by a profiler. Note that the timer
invocation will not interrupt JavaScript code.

Fixes: #11401

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

inspector: implemented two client methods.

@eugeneo eugeneo added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol labels Jul 18, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x inspector Issues and PRs related to the V8 inspector protocol labels Jul 18, 2017
@@ -527,13 +555,25 @@ class NodeInspectorClient : public v8_inspector::V8InspectorClient {
return channel_.get();
}

void startRepeatingTimer(double interval, TimerCallback callback, void* data)
override {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I’d align the arguments vertically instead, that seems a bit more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

public:
RepeatingInspectorTimer(uv_loop_t* loop, double interval,
v8_inspector::V8InspectorClient::TimerCallback callback,
void* data) : timer_(uv_timer_t()), callback_(callback),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t just timer_() work as well?

Also, I’d really rather align the arguments (and intializers) vertically for readability here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

void* data) : timer_(uv_timer_t()), callback_(callback),
data_(data) {
uv_timer_init(loop, &timer_);
int64_t interval_ms = 1000 * interval;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a question, not a request to change anything: Does V8 have any documention saying that this interval is supposed to be given in seconds? Where would one find that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. I tried to find it myself... This code originally came from Chrome where it seem to be dated back to WebKit days.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 18, 2017

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!

RepeatingInspectorTimer(const RepeatingInspectorTimer&) = delete;

~RepeatingInspectorTimer() {
uv_timer_stop(&timer_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should uv_close() the timer (and not free the memory until the close callback is called.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Thanks for pointing it out! I fixed it.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 24, 2017

@bnoordhuis Please take a look.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 25, 2017

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 25, 2017

I'm waiting for arm-fanned CI bot to recover - not feeling confident enough to push this without as little as compiling on all platforms.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 26, 2017

@eugeneo eugeneo closed this Jul 26, 2017
@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 26, 2017

Landed as 012206e

@eugeneo eugeneo deleted the timers branch July 26, 2017 23:33
@eugeneo eugeneo merged commit 012206e into nodejs:master Jul 26, 2017
addaleax pushed a commit that referenced this pull request Jul 27, 2017
This timer is currently only used by a profiler. Note that the timer
invocation will not interrupt JavaScript code.

Fixes: #11401
PR-URL: #14346
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@addaleax addaleax mentioned this pull request Aug 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inspector Record Allocation Timeline bugged
7 participants