| Server IP : 82.148.16.210 / Your IP : 216.73.216.19 Web Server : nginx/1.29.5 System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64 User : root ( 0) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/usr/include/nodejs/src/ |
Upload File : |
#ifndef SRC_TIMER_WRAP_H_
#define SRC_TIMER_WRAP_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "memory_tracker.h"
#include "env.h"
#include "uv.h"
#include <functional>
namespace node {
// Utility class that makes working with libuv timers a bit easier.
class TimerWrap final : public MemoryRetainer {
public:
using TimerCb = std::function<void()>;
template <typename... Args>
explicit inline TimerWrap(Environment* env, Args&&... args);
TimerWrap(const TimerWrap&) = delete;
inline Environment* env() const { return env_; }
// Stop calling the timer callback.
void Stop();
// Render the timer unusable and delete this object.
void Close();
// Starts / Restarts the Timer
void Update(uint64_t interval, uint64_t repeat = 0);
void Ref();
void Unref();
SET_NO_MEMORY_INFO()
SET_MEMORY_INFO_NAME(TimerWrap)
SET_SELF_SIZE(TimerWrap)
private:
static void TimerClosedCb(uv_handle_t* handle);
static void OnTimeout(uv_timer_t* timer);
~TimerWrap() = default;
Environment* env_;
TimerCb fn_;
uv_timer_t timer_;
friend std::unique_ptr<TimerWrap>::deleter_type;
};
class TimerWrapHandle : public MemoryRetainer {
public:
template <typename... Args>
explicit inline TimerWrapHandle(Environment* env, Args&&... args);
TimerWrapHandle(const TimerWrapHandle&) = delete;
~TimerWrapHandle() { Close(); }
void Update(uint64_t interval, uint64_t repeat = 0);
void Ref();
void Unref();
void Stop();
void Close();
void MemoryInfo(node::MemoryTracker* tracker) const override;
SET_MEMORY_INFO_NAME(TimerWrapHandle)
SET_SELF_SIZE(TimerWrapHandle)
private:
static void CleanupHook(void* data);
TimerWrap* timer_;
};
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_TIMER_WRAP_H_