Async 1.8.0
|
A timer that times out at a specified absolute time. More...
#include <AsyncAtTimer.h>
Public Member Functions | |
AtTimer (void) | |
Default constructor. | |
AtTimer (struct tm &tm, bool do_start=true) | |
Constuctor. | |
~AtTimer (void) | |
Destructor. | |
bool | setTimeout (time_t t) |
Set the timeout time. | |
bool | setTimeout (struct tm &tm) |
Set the timeout time. | |
void | setExpireOffset (int offset_ms) |
Set the expire offset. | |
bool | start (void) |
Start the timer. | |
void | stop (void) |
Stop the timer. | |
Public Attributes | |
sigc::signal< void, AtTimer * > | expired |
A signal that is emitted when the timer expires. | |
A timer that times out at a specified absolute time.
This class is used to get a timeout at a specified absolute time. That is, you can specify a time of day, like 2013-04-06 12:43:00, when you would like the timer to expire.
This class use the gettimeofday() function as its time reference. If reading time using another function, like time(), in the expire callback, you can not be sure to get the same time value. The gettimeofday() and time() functions may return different values for the second. The offset usually seem to be small (~10ms) but this has not been tested very much. One way to get around the problem, if it's not possible to use the gettimeofday() function, is to set an offset using the setExpireOffset() method. An offset of 100ms will probably do.
Definition at line 136 of file AsyncAtTimer.h.
Async::AtTimer::AtTimer | ( | void | ) |
Default constructor.
After default construction the timer will be disabled.
|
explicit |
Constuctor.
tm | When the timer should expire in local time |
do_start | Set to true (default) if the timer should start upon creation |
Async::AtTimer::~AtTimer | ( | void | ) |
Destructor.
void Async::AtTimer::setExpireOffset | ( | int | offset_ms | ) |
Set the expire offset.
offset_ms | The expire offset in milliseconds |
Use this function to set an offset for the timer expiration. For example, if the offset is set to 100ms, the timer will expire 100ms after the time of day specification. It is also possible to set the offset to a negative value.
Referenced by Async::StateMachine< ContextT, StateTopT >::setTimeoutAt().
bool Async::AtTimer::setTimeout | ( | struct tm & | tm | ) |
Set the timeout time.
tm | When the timer should expire in broken down local time |
bool Async::AtTimer::setTimeout | ( | time_t | t | ) |
Set the timeout time.
t | When the timer should expire in seconds since the epoch |
Referenced by Async::StateMachine< ContextT, StateTopT >::setTimeoutAt().
bool Async::AtTimer::start | ( | void | ) |
Start the timer.
Referenced by Async::StateMachine< ContextT, StateTopT >::setTimeoutAt().
void Async::AtTimer::stop | ( | void | ) |
Stop the timer.
Referenced by Async::StateMachine< ContextT, StateTopT >::clearTimeoutAt().
sigc::signal<void, AtTimer *> Async::AtTimer::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 203 of file AsyncAtTimer.h.
Referenced by Async::StateMachine< ContextT, StateTopT >::StateMachine().