CARMA C++
|
Timer object that fires at a fixed offset after every Nth CARMA frame time. More...
#include <carma/util/FrameAlignedTimer.h>
Public Member Functions | |
FrameAlignedTimer (long offsetNanos=0, long periodFrames=1, bool preflight=true) | |
Construct an instance with the given offset and period. More... | |
struct::timespec | getNextFireTime () |
struct::timespec | ResetNextFireTime (long delayFrames=0) |
Reset the next fire time (and by association the entire queue of fire times) to the soonest absolute time that is the correct offset from a CARMA frame time and also is at least delayFrames CARMA frames after the time of the call and then return that new next fire absolute time. More... | |
struct::timespec | ResetNextFireTimeAndWait (long delayFrames=0) |
Same as ResetNextFireTime( ) 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. More... | |
![]() | |
void | InterruptPresentOrNextWait () |
Interrupt the wait that is presently occurring on this timer object or if no such wait is presently occurring then preemptively interrupt the next wait that occurs. More... | |
void | WaitForNextFireTime () |
Block (the thread of the caller) until the next fire time for the timer arrives. More... | |
Protected Member Functions | |
virtual Timespec | CalculateNextFireAbsoluteTime (const Timespec &fireAbsTime) |
Timespec | InternalResetNextFireTime (long delayFrames, bool wait) |
![]() | |
void | refreshNextFireAbsTimeIfNeeded (Timespec *nextFireAbsTime) |
ScheduledTimer (bool preflight) | |
void | SetNextFireTime (const Timespec &nextFireAbsTime) |
void | SetNextFireTimeAndWait (const Timespec &nextFireAbsTime) |
Additional Inherited Members | |
![]() | |
typedef struct::timespec | Timespec |
![]() | |
static void | sanityCheckTimespec (const Timespec &ts) |
Timer object that fires at a fixed offset after every Nth CARMA frame time.
Definition at line 20 of file FrameAlignedTimer.h.
|
explicit |
Construct an instance with the given offset and period.
If any parameters are invalid or an internal error occurs then an exception will be thrown.
offsetNanos | Offset in nanoseconds from the CARMA frame time to the fire time for the instance. The value must be greater than 0 and less than the CARMA frame period in nanoseconds. |
periodFrames | How often (in integral CARMA frame periods) the 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). |
offsetNanos
is greater than 0 and less than the CARMA frame period in nanoseconds.periodFrames
is greater than 0. struct ::timespec carma::util::FrameAlignedTimer::ResetNextFireTime | ( | long | delayFrames = 0 | ) |
Reset the next fire time (and by association the entire queue of fire times) to the soonest absolute time that is the correct offset from a CARMA frame time and also is at least delayFrames
CARMA frames after the time of the call and then return that new next fire absolute time.
All old fire times are removed from the queue as though they never existed.
delayFrames | minimum number of CARMA frames to delay the next fire time after the time of the call. |
delayFrames
is greater than or equal to 0.struct ::timespec carma::util::FrameAlignedTimer::ResetNextFireTimeAndWait | ( | long | delayFrames = 0 | ) |
Same as ResetNextFireTime( ) 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.