Skip to content

Commit

Permalink
src: make watchdog async callback a lambda
Browse files Browse the repository at this point in the history
`Watchdog::Async` features only once for the
async callback, so make it a lambda.

PR-URL: #25945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
gireeshpunathil authored and addaleax committed Feb 8, 2019
1 parent de9f37d commit 55a313b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/node_watchdog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms, bool* timed_out)
"Failed to initialize uv loop.");
}

rc = uv_async_init(loop_, &async_, &Watchdog::Async);
rc = uv_async_init(loop_, &async_, [](uv_async_t* signal) {
Watchdog* w = ContainerOf(&Watchdog::async_, signal);
uv_stop(w->loop_);
});

CHECK_EQ(0, rc);

rc = uv_timer_init(loop_, &timer_);
Expand Down Expand Up @@ -80,13 +84,6 @@ void Watchdog::Run(void* arg) {
uv_close(reinterpret_cast<uv_handle_t*>(&wd->timer_), nullptr);
}


void Watchdog::Async(uv_async_t* async) {
Watchdog* w = ContainerOf(&Watchdog::async_, async);
uv_stop(w->loop_);
}


void Watchdog::Timer(uv_timer_t* timer) {
Watchdog* w = ContainerOf(&Watchdog::timer_, timer);
*w->timed_out_ = true;
Expand Down
1 change: 0 additions & 1 deletion src/node_watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class Watchdog {

private:
static void Run(void* arg);
static void Async(uv_async_t* async);
static void Timer(uv_timer_t* timer);

v8::Isolate* isolate_;
Expand Down

0 comments on commit 55a313b

Please sign in to comment.