summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGireesh Punathil <gpunathi@in.ibm.com>2019-02-05 09:05:30 -0500
committerGireesh Punathil <gpunathi@in.ibm.com>2019-02-08 13:01:25 +0530
commit7182aca108fac7a7e464e9450461975e6ef4a4e3 (patch)
tree239fa7286df52690e2180df252d20e1a58e1f351
parent3a02d39df9f156ae12fac42f8ced75394bf67f0f (diff)
downloadandroid-node-v8-7182aca108fac7a7e464e9450461975e6ef4a4e3.tar.gz
android-node-v8-7182aca108fac7a7e464e9450461975e6ef4a4e3.tar.bz2
android-node-v8-7182aca108fac7a7e464e9450461975e6ef4a4e3.zip
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 <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--src/node_watchdog.cc13
-rw-r--r--src/node_watchdog.h1
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<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;
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_;