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>
This commit is contained in:
parent
3a02d39df9
commit
7182aca108
@ -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;
|
||||
|
@ -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_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user