Skip to content

Commit 55a313b

Browse files
gireeshpunathiladdaleax
authored andcommitted
src: make watchdog async callback a lambda
`Watchdog::Async` features only once for the async callback, so make it a lambda. PR-URL: #25945 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent de9f37d commit 55a313b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/node_watchdog.cc

+5-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms, bool* timed_out)
3939
"Failed to initialize uv loop.");
4040
}
4141

42-
rc = uv_async_init(loop_, &async_, &Watchdog::Async);
42+
rc = uv_async_init(loop_, &async_, [](uv_async_t* signal) {
43+
Watchdog* w = ContainerOf(&Watchdog::async_, signal);
44+
uv_stop(w->loop_);
45+
});
46+
4347
CHECK_EQ(0, rc);
4448

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

83-
84-
void Watchdog::Async(uv_async_t* async) {
85-
Watchdog* w = ContainerOf(&Watchdog::async_, async);
86-
uv_stop(w->loop_);
87-
}
88-
89-
9087
void Watchdog::Timer(uv_timer_t* timer) {
9188
Watchdog* w = ContainerOf(&Watchdog::timer_, timer);
9289
*w->timed_out_ = true;

src/node_watchdog.h

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class Watchdog {
4545

4646
private:
4747
static void Run(void* arg);
48-
static void Async(uv_async_t* async);
4948
static void Timer(uv_timer_t* timer);
5049

5150
v8::Isolate* isolate_;

0 commit comments

Comments
 (0)