| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a5a1691 commit 3be49d6
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -642,6 +642,7 @@ | |||
| 642 | 642 | 'src/tracing/trace_event_common.h', | |
| 643 | 643 | 'src/tracing/traced_value.h', | |
| 644 | 644 | 'src/timer_wrap.h', | |
| 645 | + 'src/timer_wrap-inl.h', | ||
| 645 | 646 | 'src/tty_wrap.h', | |
| 646 | 647 | 'src/udp_wrap.h', | |
| 647 | 648 | 'src/util.h', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ | |||
| 15 | 15 | #include "node_process-inl.h" | |
| 16 | 16 | #include "node_url.h" | |
| 17 | 17 | #include "util-inl.h" | |
| 18 | - #include "timer_wrap.h" | ||
| 18 | + #include "timer_wrap-inl.h" | ||
| 19 | 19 | #include "v8-inspector.h" | |
| 20 | 20 | #include "v8-platform.h" | |
| 21 | 21 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 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,17 +1,12 @@ | |||
| 1 | + #include "timer_wrap.h" // NOLINT(build/include_inline) | ||
| 2 | + #include "timer_wrap-inl.h" | ||
| 3 | + | ||
| 1 | 4 | #include "env-inl.h" | |
| 2 | 5 | #include "memory_tracker-inl.h" | |
| 3 | - #include "timer_wrap.h" | ||
| 4 | 6 | #include "uv.h" | |
| 5 | 7 | ||
| 6 | 8 | namespace node { | |
| 7 | 9 | ||
| 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 | - | ||
| 15 | 10 | void TimerWrap::Stop() { | |
| 16 | 11 | if (timer_.data == nullptr) return; | |
| 17 | 12 | uv_timer_stop(&timer_); | |
@@ -48,13 +43,6 @@ void TimerWrap::OnTimeout(uv_timer_t* timer) { | |||
| 48 | 43 | t->fn_(); | |
| 49 | 44 | } | |
| 50 | 45 | ||
| 51 | - TimerWrapHandle::TimerWrapHandle( | ||
| 52 | - Environment* env, | ||
| 53 | - const TimerWrap::TimerCb& fn) { | ||
| 54 | - timer_ = new TimerWrap(env, fn); | ||
| 55 | - env->AddCleanupHook(CleanupHook, this); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | 46 | void TimerWrapHandle::Stop() { | |
| 59 | 47 | if (timer_ != nullptr) | |
| 60 | 48 | return timer_->Stop(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,9 @@ class TimerWrap final : public MemoryRetainer { | |||
| 16 | 16 | public: | |
| 17 | 17 | using TimerCb = std::function<void()>; | |
| 18 | 18 | ||
| 19 | - TimerWrap(Environment* env, const TimerCb& fn); | ||
| 19 | + template <typename... Args> | ||
| 20 | + explicit inline TimerWrap(Environment* env, Args&&... args); | ||
| 21 | + | ||
| 20 | 22 | TimerWrap(const TimerWrap&) = delete; | |
| 21 | 23 | ||
| 22 | 24 | inline Environment* env() const { return env_; } | |
@@ -50,9 +52,8 @@ class TimerWrap final : public MemoryRetainer { | |||
| 50 | 52 | ||
| 51 | 53 | class TimerWrapHandle : public MemoryRetainer { | |
| 52 | 54 | public: | |
| 53 | - TimerWrapHandle( | ||
| 54 | - Environment* env, | ||
| 55 | - const TimerWrap::TimerCb& fn); | ||
| 55 | + template <typename... Args> | ||
| 56 | + explicit inline TimerWrapHandle(Environment* env, Args&&... args); | ||
| 56 | 57 | ||
| 57 | 58 | TimerWrapHandle(const TimerWrapHandle&) = delete; | |
| 58 | 59 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments