Skip to content

Commit

Permalink
src: make node::SignalWrap::OnSignal into lambda
Browse files Browse the repository at this point in the history
PR-URL: #26184
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
gireeshpunathil authored and rvagg committed Feb 28, 2019
1 parent 8a551b9 commit 831aa9a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/signal_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ class SignalWrap : public HandleWrap {
}
}
#endif
int err = uv_signal_start(&wrap->handle_, OnSignal, signum);
int err = uv_signal_start(
&wrap->handle_,
[](uv_signal_t* handle, int signum) {
SignalWrap* wrap = ContainerOf(&SignalWrap::handle_, handle);
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
Local<Value> arg = Integer::New(env->isolate(), signum);
wrap->MakeCallback(env->onsignal_string(), 1, &arg);
},
signum);
args.GetReturnValue().Set(err);
}

Expand All @@ -112,16 +122,6 @@ class SignalWrap : public HandleWrap {
args.GetReturnValue().Set(err);
}

static void OnSignal(uv_signal_t* handle, int signum) {
SignalWrap* wrap = ContainerOf(&SignalWrap::handle_, handle);
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());

Local<Value> arg = Integer::New(env->isolate(), signum);
wrap->MakeCallback(env->onsignal_string(), 1, &arg);
}

uv_signal_t handle_;
};

Expand Down

0 comments on commit 831aa9a

Please sign in to comment.