#include <icy/timer.h>Inherits:
Runner
Asynchronous event based timer.
NullSignal TimeoutSignal that gets triggered on timeout.
| Return | Name | Description |
|---|---|---|
Timer | Create a timer without a timeout or interval; values must be set before [start()](#start-12). | |
Timer | Create a one-shot timer that fires after timeout milliseconds. | |
Timer | Create a repeating timer with an initial delay and a repeat period. | |
~Timer virtual | Destructor. | |
void | start | Start the timer using the previously configured timeout and interval. |
void | start virtual | Connect func to the [Timeout](icy-Timeout.html#timeout-1) signal and start the timer. |
void | stop | Stop the timer. Resets the fire count to zero. |
void | restart | Restart the timer. |
void | again | Reset the countdown without stopping and restarting the timer. |
void | setTimeout | Set the initial delay before the first timeout event. |
void | setInterval | Set the repeat interval (calls uv_timer_set_repeat). |
bool | active const | #### Returns |
std::int64_t | timeout const | #### Returns |
std::int64_t | interval const | #### Returns |
std::int64_t | count | #### Returns |
uv::Handle< uv_timer_t > & | handle | #### Returns |
bool | async virtual const | #### Returns |
Timer(uv::Loop * loop)Create a timer without a timeout or interval; values must be set before [start()](#start-12).
loop Event loop to associate with. Defaults to the process-wide default loop.Timer(std::int64_t timeout, uv::Loop * loop, std::function< void()> func)Create a one-shot timer that fires after timeout milliseconds.
If func is provided the timer starts immediately; otherwise call [start()](#start-12) manually.
timeout Delay in milliseconds before the first (and only) fire.
loop Event loop to associate with.
func Optional callback connected to the [Timeout](icy-Timeout.html#timeout-1) signal and used to start the timer immediately.
Timer(std::int64_t timeout, std::int64_t interval, uv::Loop * loop, std::function< void()> func)Create a repeating timer with an initial delay and a repeat period.
Fires once after timeout milliseconds, then repeatedly every interval milliseconds. If func is provided the timer starts immediately; otherwise call [start()](#start-12) manually.
timeout Initial delay in milliseconds.
interval Repeat period in milliseconds.
loop Event loop to associate with.
func Optional callback connected to the [Timeout](icy-Timeout.html#timeout-1) signal and used to start the timer immediately.
virtual
virtual ~Timer()Destructor.
void start()Start the timer using the previously configured timeout and interval.
Throws std::logic_error if neither a timeout nor an interval has been set, or if the handle has not been allocated. Has no effect if already active.
virtual
virtual void start(std::function< void()> func)Connect func to the [Timeout](icy-Timeout.html#timeout-1) signal and start the timer.
func Callback invoked on each timeout event.void stop()Stop the timer. Resets the fire count to zero.
Has no effect if the timer is not active.
void restart()Restart the timer.
If the timer is not currently active, behaves like [start()](#start-12). If it is active, calls [again()](#again) to reset the countdown using the repeat value. A timeout or interval must be set beforehand, otherwise [start()](#start-12) will throw std::logic_error.
void again()Reset the countdown without stopping and restarting the timer.
For repeating timers this restarts the repeat interval from now. For non-repeating timers this has the same effect as stopping the timer. Throws on error if uv_timer_again fails (e.g. the timer was never started). Resets the fire count to zero.
void setTimeout(std::int64_t timeout)Set the initial delay before the first timeout event.
Has no effect if the timer is currently active.
timeout Delay in milliseconds.void setInterval(std::int64_t interval)Set the repeat interval (calls uv_timer_set_repeat).
Takes effect from the next timeout event. If set from within a timer callback on a repeating timer, the new value is used from the following iteration; on a non-repeating timer the timer will have already stopped.
interval Repeat period in milliseconds; 0 disables repeating.const
bool active() consttrue if the timer is currently counting down.
const
std::int64_t timeout() constThe configured initial timeout in milliseconds.
const
std::int64_t interval() constThe effective repeat interval reported by libuv, in milliseconds.
std::int64_t count()The number of times the timer has fired since the last start or again().
uv::Handle< uv_timer_t > & handle()Reference to the underlying uv_timer_t handle wrapper.
virtual const
virtual bool async() constfalse; the timer is event-loop-driven, not thread-based.
| Return | Name | Description |
|---|---|---|
uv::Handle< uv_timer_t > | _handle | |
std::int64_t | _timeout | |
std::int64_t | _interval | |
std::int64_t | _count |
uv::Handle< uv_timer_t > _handlestd::int64_t _timeoutstd::int64_t _intervalstd::int64_t _countTimer(const Timer &) = deleteDeleted constructor.
Timer(Timer &&) = deleteDeleted constructor.
void init()