File tree Expand file tree Collapse file tree 3 files changed +9
-13
lines changed Expand file tree Collapse file tree 3 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -525,7 +525,7 @@ class NodeInspectorClient : public V8InspectorClient {
525525 void * data) override {
526526 auto result =
527527 timers_.emplace (std::piecewise_construct, std::make_tuple (data),
528- std::make_tuple (env_, callback, data));
528+ std::make_tuple (env_, [=]() { callback ( data); } ));
529529 CHECK (result.second );
530530 uint64_t interval = 1000 * interval_s;
531531 result.first ->second .Update (interval, interval);
Original file line number Diff line number Diff line change 55
66namespace node {
77
8- TimerWrap::TimerWrap (Environment* env, TimerCb fn, void * user_data )
8+ TimerWrap::TimerWrap (Environment* env, const TimerCb& fn)
99 : env_(env),
10- fn_ (fn),
11- user_data_(user_data) {
10+ fn_ (fn) {
1211 uv_timer_init (env->event_loop (), &timer_);
1312 timer_.data = this ;
1413}
@@ -45,14 +44,13 @@ void TimerWrap::Unref() {
4544
4645void TimerWrap::OnTimeout (uv_timer_t * timer) {
4746 TimerWrap* t = ContainerOf (&TimerWrap::timer_, timer);
48- t->fn_ (t-> user_data_ );
47+ t->fn_ ();
4948}
5049
5150TimerWrapHandle::TimerWrapHandle (
5251 Environment* env,
53- TimerWrap::TimerCb fn,
54- void * user_data) {
55- timer_ = new TimerWrap (env, fn, user_data);
52+ const TimerWrap::TimerCb& fn) {
53+ timer_ = new TimerWrap (env, fn);
5654 env->AddCleanupHook (CleanupHook, this );
5755}
5856
Original file line number Diff line number Diff line change @@ -14,9 +14,9 @@ namespace node {
1414// Utility class that makes working with libuv timers a bit easier.
1515class TimerWrap final : public MemoryRetainer {
1616 public:
17- using TimerCb = std::function<void (void * )>;
17+ using TimerCb = std::function<void ()>;
1818
19- TimerWrap (Environment* env, TimerCb fn, void * user_data );
19+ TimerWrap (Environment* env, const TimerCb& fn);
2020 TimerWrap (const TimerWrap&) = delete ;
2121
2222 inline Environment* env () const { return env_; }
@@ -43,7 +43,6 @@ class TimerWrap final : public MemoryRetainer {
4343 Environment* env_;
4444 TimerCb fn_;
4545 uv_timer_t timer_;
46- void * user_data_ = nullptr ;
4746
4847 friend std::unique_ptr<TimerWrap>::deleter_type;
4948};
@@ -52,8 +51,7 @@ class TimerWrapHandle : public MemoryRetainer {
5251 public:
5352 TimerWrapHandle (
5453 Environment* env,
55- TimerWrap::TimerCb fn,
56- void * user_data = nullptr );
54+ const TimerWrap::TimerCb& fn);
5755
5856 TimerWrapHandle (const TimerWrapHandle&) = delete ;
5957
You can’t perform that action at this time.
0 commit comments