Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-07-08 02:42:07 +0300
committerAnna Henningsen <anna@addaleax.net>2020-07-14 16:04:43 +0300
commite2f9dc6e5a82392dad4f4451fa56edd178ac0e8f (patch)
tree0b80e520662e74e8832335eaedd0552bcae5f7fe /src/timer_wrap.cc
parent18667ac6f54a4a2a781f1cf6380ac0660196e5e5 (diff)
src: remove user_data from TimerWrap
There’s no point in having an opaque user data pointer when we’re already using `std::function`. PR-URL: https://github.com/nodejs/node/pull/34252 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r--src/timer_wrap.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc
index 618c50c82e2..919b629348c 100644
--- a/src/timer_wrap.cc
+++ b/src/timer_wrap.cc
@@ -5,10 +5,9 @@
namespace node {
-TimerWrap::TimerWrap(Environment* env, TimerCb fn, void* user_data)
+TimerWrap::TimerWrap(Environment* env, const TimerCb& fn)
: env_(env),
- fn_(fn),
- user_data_(user_data) {
+ fn_(fn) {
uv_timer_init(env->event_loop(), &timer_);
timer_.data = this;
}
@@ -45,14 +44,13 @@ void TimerWrap::Unref() {
void TimerWrap::OnTimeout(uv_timer_t* timer) {
TimerWrap* t = ContainerOf(&TimerWrap::timer_, timer);
- t->fn_(t->user_data_);
+ t->fn_();
}
TimerWrapHandle::TimerWrapHandle(
Environment* env,
- TimerWrap::TimerCb fn,
- void* user_data) {
- timer_ = new TimerWrap(env, fn, user_data);
+ const TimerWrap::TimerCb& fn) {
+ timer_ = new TimerWrap(env, fn);
env->AddCleanupHook(CleanupHook, this);
}