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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
gireeshpunathil committed Feb 21, 2019
1 parent 83e1b97 commit dbfe14c
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 dbfe14c

Please sign in to comment.