CARMA C++
carma::util::ScheduledTimer Class Referenceabstract

Abstract base class for PthreadCond::TimedWait based timers. More...

#include <carma/util/ScheduledTimer.h>

Inheritance diagram for carma::util::ScheduledTimer:
carma::util::FrameAlignedTimer carma::util::PeriodicTimer

Public Member Functions

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 Types

typedef struct::timespec Timespec
 

Protected Member Functions

virtual Timespec CalculateNextFireAbsoluteTime (const Timespec &fireAbsTime)=0
 
void refreshNextFireAbsTimeIfNeeded (Timespec *nextFireAbsTime)
 
 ScheduledTimer (bool preflight)
 
void SetNextFireTime (const Timespec &nextFireAbsTime)
 
void SetNextFireTimeAndWait (const Timespec &nextFireAbsTime)
 

Static Protected Member Functions

static void sanityCheckTimespec (const Timespec &ts)
 

Detailed Description

Abstract base class for PthreadCond::TimedWait based timers.

ScheduledTimer provides an abstract base class for PthreadCond::TimedWait based timers. Instances of ScheduledTimer (and of derived classes, unless their documentation says otherwise) are only intended to be used from a single thread. The behavior is undefined if multiple threads attempt to wait on the same ScheduledTimer instance. It is however, safe to have multiple threads waiting on distinct ScheduledTimer instances.

Definition at line 20 of file ScheduledTimer.h.

Member Function Documentation

void carma::util::ScheduledTimer::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.

This is the one method that can be called by any thread other than the owning thread of the timer object.

void carma::util::ScheduledTimer::WaitForNextFireTime ( )

Block (the thread of the caller) until the next fire time for the timer arrives.

That fire time is then popped from the queue of fire times. If the next fire time has already passed then this method will pop that fire time and return immediately without blocking. If multiple fire times have already passed then subsequent calls to this method will also return immediately until all fire times that have already passed have been popped from the queue. Any internal errors will throw an exception.


The documentation for this class was generated from the following file: