From 7182aca108fac7a7e464e9450461975e6ef4a4e3 Mon Sep 17 00:00:00 2001 From: Gireesh Punathil Date: Tue, 5 Feb 2019 09:05:30 -0500 Subject: src: make watchdog async callback a lambda `Watchdog::Async` features only once for the async callback, so make it a lambda. PR-URL: https://github.com/nodejs/node/pull/25945 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- src/node_watchdog.cc | 13 +++++-------- src/node_watchdog.h | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index 9ef7bafede..482d590a52 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -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_); @@ -80,13 +84,6 @@ void Watchdog::Run(void* arg) { uv_close(reinterpret_cast(&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; diff --git a/src/node_watchdog.h b/src/node_watchdog.h index 2cc7eab837..9c56b90e9e 100644 --- a/src/node_watchdog.h +++ b/src/node_watchdog.h @@ -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_; -- cgit v1.2.3