Timer object that fires at a fixed rate.
More...
#include <carma/util/PeriodicTimer.h>
|
virtual struct::timespec | CalculateNextFireAbsoluteTime (const struct::timespec &fireAbsoluteTime) |
|
void | refreshNextFireAbsTimeIfNeeded (Timespec *nextFireAbsTime) |
|
| ScheduledTimer (bool preflight) |
|
void | SetNextFireTime (const Timespec &nextFireAbsTime) |
|
void | SetNextFireTimeAndWait (const Timespec &nextFireAbsTime) |
|
|
typedef struct::timespec | Timespec |
|
static void | sanityCheckTimespec (const Timespec &ts) |
|
Timer object that fires at a fixed rate.
- Warning
- An instance is NOT ready to wait on simply by being constructed. You MUST reset an instance's next fire time before (or at the same time as) the first wait on an instance.
- Note
- If you want a timer that fires at a fixed offset after every Nth CARMA frame time then consider using an instance of FrameAlignedTimer instead.
Definition at line 23 of file PeriodicTimer.h.
carma::util::PeriodicTimer::PeriodicTimer |
( |
const struct::timespec & |
period, |
|
|
bool |
preflight = true |
|
) |
| |
|
explicit |
Construct an instance with the given period.
If any parameters are invalid or an internal error occurs then an exception will be thrown.
- Parameters
-
period | How often in absolute time this instance will fire. The value must be greater than 0. |
preflight | If true then the instance will be preflighted as part of construction. Preflighting involves actually performing a very quick wait and/or test on the internal primitives used to implement the instance. This MAY reduce any increased one-time latency and/or drift in the first wait on the instance (on some operating systems). |
- Precondition
period
is greater than 0.
carma::util::PeriodicTimer::PeriodicTimer |
( |
const struct::timeval & |
period, |
|
|
bool |
preflight = true |
|
) |
| |
|
explicit |
void carma::util::PeriodicTimer::ResetNextFireAbsoluteTime |
( |
const struct::timespec & |
nextFireAbsoluteTime | ) |
|
Reset the next fire time (and by association the entire queue of fire times) for this instance.
All old fire times for this instance are removed from the queue as though they never existed.
- Parameters
-
nextFireAbsoluteTime | absolute time for the new next fire time for this instance. |
void carma::util::PeriodicTimer::ResetNextFireAbsoluteTime |
( |
const struct::timeval & |
nextFireAbsoluteTime | ) |
|
void carma::util::PeriodicTimer::ResetNextFireAbsoluteTimeAndWait |
( |
const struct::timespec & |
nextFireAbsoluteTime | ) |
|
Same as ResetNextFireAbsoluteTime( const struct ::timespec & ) except that this method also waits for the new next fire time to arrive before returning the new next fire time that it has just waited for.
- Postcondition
- Either absolute time is greater than or equal to the fire time returned or an exception has been thrown.
void carma::util::PeriodicTimer::ResetNextFireAbsoluteTimeAndWait |
( |
const struct::timeval & |
nextFireAbsoluteTime | ) |
|
The documentation for this class was generated from the following file: