Notifies clients in constant intervals. More...
|Default constructor. More...|
|Detach from used event loop. |
|std::size_t||interval () const|
|Returns the current timer interval in milliseconds. |
|bool||isStarted () const|
|Returs true if timer was started. |
|EventLoop *||loop ()|
|Returns the used event loop. |
|void||setActive (EventLoop &loop)|
|Sets the used event loop. |
|void||start (std::size_t interval)|
|Starts the timer. More...|
|Stops the timer. More...|
|Signal &||timeout ()|
|Notifies about interval timeouts. More...|
Timers can be used to be notified if a time interval expires. It usually works with an event loop, where the Timer needs to be registered. Timers send the timeout signal in given intervals, to which the interested clients connect. The interval can be changed at any time and timers can switch between an active and inactive state.
The following code calls the function onTimer every second:
Constructs an inactive timer.
The destructor sends the destroyed signal.
Start a timer from the moment this method is called. The Timer needs to be registered with an event loop, otherwise the timeout signal will not be sent.
|interval||Timeout interval in milliseconds|
If the Timer is registered with an event loop, the timout signal will not be sent anymore.
This signal is sent if the interval time has expired.