Async
1.3.1
|
A class that produces timer events. More...
#include <AsyncTimer.h>
Public Types | |
enum | Type { TYPE_ONESHOT, TYPE_PERIODIC } |
The type of the timer. More... | |
Public Member Functions | |
Timer (int timeout_ms=0, Type type=TYPE_ONESHOT) | |
Constructor. More... | |
~Timer (void) | |
Destructor. More... | |
Type | type (void) const |
Return the type of this timer. More... | |
void | setTimeout (int timeout_ms) |
Set (change) the timeout value. More... | |
int | timeout (void) const |
Return the setting of the timeout value. More... | |
void | setEnable (bool do_enable) |
Enable or disable the timer. More... | |
bool | isEnabled (void) const |
Check if the timer is enabled. More... | |
void | reset (void) |
Reset (restart) the timer. More... | |
Public Attributes | |
sigc::signal< void, Timer * > | expired |
A signal that is emitted when the timer expires. More... | |
A class that produces timer events.
This class is used to create timer objects. These objects will emit a signal when the specified time has elapsed. An example of how to use it is shown below.
Definition at line 116 of file AsyncTimer.h.
enum Async::Timer::Type |
The type of the timer.
Enumerator | |
---|---|
TYPE_ONESHOT |
A timer that expires once. |
TYPE_PERIODIC |
A timer that restarts itself every time it expires. |
Definition at line 122 of file AsyncTimer.h.
Async::Timer::Timer | ( | int | timeout_ms = 0 , |
Type | type = TYPE_ONESHOT |
||
) |
Constructor.
timeout_ms | The timeout value in milliseconds |
type | The type of timer to use (see Type) |
If no arguments are given (default constructor) a timer that expires immediately will be created. Such a timer can for example be used to delay the execution of some function until all active callbacks have returned.
Async::Timer::~Timer | ( | void | ) |
Destructor.
|
inline |
Check if the timer is enabled.
Definition at line 180 of file AsyncTimer.h.
void Async::Timer::reset | ( | void | ) |
Reset (restart) the timer.
This function is used to reset the timer. After reset it will take timeout milliseconds before the timer expires, where timeout is the previously set timeout value. If the timer is disabled, this function will do nothing.
void Async::Timer::setEnable | ( | bool | do_enable | ) |
Enable or disable the timer.
do_enable | Set to true to enable the timer or false to disable it |
void Async::Timer::setTimeout | ( | int | timeout_ms | ) |
Set (change) the timeout value.
timeout_ms | The new timeout value in milliseconds |
Use this function to set a new timeout value on an existing timer. The timer will expire when the new timeout time has elapsed. If the timer is disabled, this function will set the new timeout value but it will not enable the timer.
|
inline |
Return the setting of the timeout value.
Definition at line 166 of file AsyncTimer.h.
|
inline |
Return the type of this timer.
Definition at line 149 of file AsyncTimer.h.
sigc::signal<void, Timer *> Async::Timer::expired |
A signal that is emitted when the timer expires.
timer | A pointer to the timer that has expired |
This signal is emitted when the timer expires. It is perfectly legal to delete the timer in the connected slot if it is known to be the only connected slot.
Definition at line 200 of file AsyncTimer.h.