File tree Expand file tree Collapse file tree 5 files changed +42
-20
lines changed Expand file tree Collapse file tree 5 files changed +42
-20
lines changed Original file line number Diff line number Diff line change 642642 'src/tracing/trace_event_common.h' ,
643643 'src/tracing/traced_value.h' ,
644644 'src/timer_wrap.h' ,
645+ 'src/timer_wrap-inl.h' ,
645646 'src/tty_wrap.h' ,
646647 'src/udp_wrap.h' ,
647648 'src/util.h' ,
Original file line number Diff line number Diff line change 1515#include " node_process-inl.h"
1616#include " node_url.h"
1717#include " util-inl.h"
18- #include " timer_wrap.h"
18+ #include " timer_wrap-inl .h"
1919#include " v8-inspector.h"
2020#include " v8-platform.h"
2121
Original file line number Diff line number Diff line change 1+ #ifndef SRC_TIMER_WRAP_INL_H_
2+ #define SRC_TIMER_WRAP_INL_H_
3+
4+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5+
6+ #include " timer_wrap.h"
7+
8+ #include < utility>
9+
10+ #include " env.h"
11+ #include " uv.h"
12+
13+ namespace node {
14+
15+ template <typename ... Args>
16+ inline TimerWrap::TimerWrap (Environment* env, Args&&... args)
17+ : env_(env), fn_(std::forward<Args>(args)...) {
18+ uv_timer_init (env->event_loop (), &timer_);
19+ timer_.data = this ;
20+ }
21+
22+ template <typename ... Args>
23+ inline TimerWrapHandle::TimerWrapHandle (Environment* env, Args&&... args) {
24+ timer_ = new TimerWrap (env, std::forward<Args>(args)...);
25+ env->AddCleanupHook (CleanupHook, this );
26+ }
27+
28+ } // namespace node
29+
30+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
31+
32+ #endif // SRC_TIMER_WRAP_INL_H_
Original file line number Diff line number Diff line change 1+ #include " timer_wrap.h" // NOLINT(build/include_inline)
2+ #include " timer_wrap-inl.h"
3+
14#include " env-inl.h"
25#include " memory_tracker-inl.h"
3- #include " timer_wrap.h"
46#include " uv.h"
57
68namespace node {
79
8- TimerWrap::TimerWrap (Environment* env, const TimerCb& fn)
9- : env_(env),
10- fn_ (fn) {
11- uv_timer_init (env->event_loop (), &timer_);
12- timer_.data = this ;
13- }
14-
1510void TimerWrap::Stop () {
1611 if (timer_.data == nullptr ) return ;
1712 uv_timer_stop (&timer_);
@@ -48,13 +43,6 @@ void TimerWrap::OnTimeout(uv_timer_t* timer) {
4843 t->fn_ ();
4944}
5045
51- TimerWrapHandle::TimerWrapHandle (
52- Environment* env,
53- const TimerWrap::TimerCb& fn) {
54- timer_ = new TimerWrap (env, fn);
55- env->AddCleanupHook (CleanupHook, this );
56- }
57-
5846void TimerWrapHandle::Stop () {
5947 if (timer_ != nullptr )
6048 return timer_->Stop ();
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ class TimerWrap final : public MemoryRetainer {
1616 public:
1717 using TimerCb = std::function<void ()>;
1818
19- TimerWrap (Environment* env, const TimerCb& fn);
19+ template <typename ... Args>
20+ explicit inline TimerWrap (Environment* env, Args&&... args);
21+
2022 TimerWrap (const TimerWrap&) = delete ;
2123
2224 inline Environment* env () const { return env_; }
@@ -50,9 +52,8 @@ class TimerWrap final : public MemoryRetainer {
5052
5153class TimerWrapHandle : public MemoryRetainer {
5254 public:
53- TimerWrapHandle (
54- Environment* env,
55- const TimerWrap::TimerCb& fn);
55+ template <typename ... Args>
56+ explicit inline TimerWrapHandle (Environment* env, Args&&... args);
5657
5758 TimerWrapHandle (const TimerWrapHandle&) = delete ;
5859
You can’t perform that action at this time.
0 commit comments