A timer that fires at regular intervals, with a resolution of 1 second. More...
#include <PulseTimer.h++>

Public Member Functions | |
| PulseTimer (uint_t interval=1, uint_t initialDelay=0) throw () | |
| Construct a new PulseTimer with the given interval and initial delay. | |
| ~PulseTimer () throw () | |
| Destructor. | |
| uint32_t | getPulseCount () const throw () |
| Get the pluse count, i.e., the number of times the timer has fired. | |
| time_ms_t | getLastPulseTime () const throw () |
| Get the time at which the timer last fired. | |
| virtual void | start () throw () |
| Start executing the thread. | |
| virtual void | stop () throw () |
| Stop execution of the thread. | |
| bool | join () throw () |
| Wait for the thread to terminate. | |
| bool | isRunning () const throw () |
| Test if the thread is currently running. | |
| bool | isDetached () const throw () |
| Test if the thread is detached. | |
| void | setPriority (Priority priority) throw () |
| Set the thread priority. | |
| Priority | getPriority () const throw () |
| Get the thread priority. | |
| void | setName (const String &name) throw () |
| Set the name of this thread. | |
| String | getName () const throw () |
| Get the name of this thread. | |
Static Public Member Functions | |
| static void | sleep (timespan_ms_t msec) throw () |
| Suspend the calling thread for the given time interval. | |
| static Thread * | currentThread () |
| Obtain a pointer to the Thread object for the calling thread. | |
| static ThreadID | currentThreadID () throw () |
| Get the calling thread's thread ID. | |
Protected Member Functions | |
| void | run () |
| Main function. | |
| void | cleanup () |
| Cleanup function. | |
| virtual void | pulse (const time_ms_t &now)=0 |
| This method is called each time the timer fires. | |
| bool | trySleep (timespan_ms_t msec) throw () |
| Suspend the thread for the given time interval, returning early if the thread was cancelled via a call to stop(). | |
| bool | testCancel () throw () |
| Test for asynchronous cancellation requests. | |
| void | yield () throw () |
| Yield the CPU to (potentially) another thread. | |
Static Protected Member Functions | |
| static void | exit () throw () |
| Exit (terminate) the calling thread. | |
A timer that fires at regular intervals, with a resolution of 1 second.
This is an abstract class; subclasses should implement the pulse() method, which is called each time the timer fires. A PulseTimer is intended to run in its own thread.
| PulseTimer | ( | uint_t | interval = 1, |
|
| uint_t | initialDelay = 0 | |||
| ) | throw () |
Construct a new PulseTimer with the given interval and initial delay.
| interval | The interval, in seconds, at which the timer will fire. Must be > 0. | |
| initialDelay | An initial delay, in seconds, before the timer should begin firing. |
| ~PulseTimer | ( | ) | throw () |
Destructor.
| void cleanup | ( | ) | [protected, virtual] |
Cleanup function.
This function will be executed by the thread just prior to termination. The default implementation is a no-op.
Reimplemented from Thread.
| Thread * currentThread | ( | ) | [static, inherited] |
Obtain a pointer to the Thread object for the calling thread.
If the calling thread is the main thread, or some other thread that was not created via commonc++, a NULL pointer is returned. Never delete the object returned by this method.
| ccxx::ThreadID currentThreadID | ( | ) | throw () [static, inherited] |
Get the calling thread's thread ID.
| void exit | ( | ) | throw () [static, protected, inherited] |
Exit (terminate) the calling thread.
| time_ms_t getLastPulseTime | ( | ) | const throw () [inline] |
Get the time at which the timer last fired.
| String getName | ( | ) | const throw () [inline, inherited] |
Get the name of this thread.
| Priority getPriority | ( | ) | const throw () [inherited] |
Get the thread priority.
| uint32_t getPulseCount | ( | ) | const throw () [inline] |
Get the pluse count, i.e., the number of times the timer has fired.
| bool isDetached | ( | ) | const throw () [inline, inherited] |
Test if the thread is detached.
| bool isRunning | ( | ) | const throw () [inherited] |
Test if the thread is currently running.
| bool join | ( | ) | throw () [inherited] |
Wait for the thread to terminate.
| virtual void pulse | ( | const time_ms_t & | now | ) | [protected, pure virtual] |
This method is called each time the timer fires.
| now | The current system time. |
| void run | ( | ) | [protected, virtual] |
| void setName | ( | const String & | name | ) | throw () [inline, inherited] |
Set the name of this thread.
| void setPriority | ( | Priority | priority | ) | throw () [inherited] |
Set the thread priority.
| void sleep | ( | timespan_ms_t | msec | ) | throw () [static, inherited] |
Suspend the calling thread for the given time interval.
| msec | The number of milliseconds to sleep. |
| void start | ( | ) | throw () [virtual, inherited] |
| void stop | ( | ) | throw () [virtual, inherited] |
Stop execution of the thread.
The thread is not forcibly killed; instead, an asynchronous cancellation request is posted to the thread. If the thread is not running, the call has no effect.
| bool testCancel | ( | ) | throw () [protected, inherited] |
Test for asynchronous cancellation requests.
| bool trySleep | ( | timespan_ms_t | msec | ) | throw () [protected, inherited] |
Suspend the thread for the given time interval, returning early if the thread was cancelled via a call to stop().
| msec | The number of milliseconds to sleep. |
| void yield | ( | ) | throw () [protected, inherited] |
Yield the CPU to (potentially) another thread.
1.6.3