Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

PollThread Class Reference

description of PollThread More...

#include <PollThread.h>

Inheritance diagram for PollThread:

Detailed Description

description of PollThread

Definition at line 13 of file PollThread.h.

List of all members.

Public Member Functions

 PollThread ()
 constructor
 PollThread (const TimeET &initial, const TimeET &freq, bool countPollTime)
 constructor
 ~PollThread ()
 destructor
virtual void start ()
 requests that the thread be started, if not already running (you need to create separate instances if you want to run multiple copies)
virtual bool getTrackPollTime ()
 returns trackPollTime
virtual void setTrackPollTime (bool countPollTime)
 sets trackPollTime

Protected Member Functions

virtual bool poll ()
 this is the function which will be called at the specified frequency, override it with your own functionality
virtual void interrupted ()
 called if a signal is sent while sleeping, should reset delay to indicate remaining sleep time, relative to startTime
virtual void * run ()
 called by launch() once the thread has been set up; when this returns, the thread ends, see runloop()

Static Protected Member Functions

static void handleInterrupt (int signal)
 called if a SIGALRM is sent (generally, by a call to interrupt())

Protected Attributes

TimeET delay
 amount of time to delay between call to start() and first call to poll(), or if interrupt occurs after first poll(), amount of time to re-sleep
TimeET period
 amount of time between calls to poll() -- if zero or negative, no delay will be made between calls (other than a call to testCancel())
TimeET startTime
 the time at which start() was called or the current period began
bool trackPollTime
 if true, the time spent in poll() is subtracted from the next sleep time so frequency is fixed; if false, period is added onto whatever time poll() takes
bool initialPoll
 set to true after start until after first call to poll has completed

Constructor & Destructor Documentation

PollThread::PollThread (  ) 

constructor

Definition at line 16 of file PollThread.h.

PollThread::PollThread ( const TimeET &  initial,
const TimeET &  freq,
bool  countPollTime 
) [explicit]

constructor

Definition at line 18 of file PollThread.h.

PollThread::~PollThread (  ) 

destructor

Definition at line 22 of file PollThread.h.


Member Function Documentation

virtual bool PollThread::getTrackPollTime (  )  [virtual]

returns trackPollTime

Definition at line 31 of file PollThread.h.

static void PollThread::handleInterrupt ( int  signal  )  [static, protected]

called if a SIGALRM is sent (generally, by a call to interrupt())

Reimplemented from Thread.

void PollThread::interrupted (  )  [protected, virtual]

called if a signal is sent while sleeping, should reset delay to indicate remaining sleep time, relative to startTime

On return, delay should be set such that delay-startTime.Age() is remaining sleep time. In other words, simply set delay to the period to maintain previously requested timing.

This default implementation will set delay to the remaining time needed to maintain current period setting. Feel free to override and reset period (or other member variables) if you need to change timing dynamically. If the period is shortened such that poll() should have already occurred based on time of previous call and the new period (plus any delay value), then poll() will be called immediately upon return.

Reimplemented from Thread.

Definition at line 24 of file PollThread.cc.

bool PollThread::poll (  )  [protected, virtual]

this is the function which will be called at the specified frequency, override it with your own functionality

Returns:
true if run() should continue, false to stop the thread. The default implementation calls runloop() and sets period to its return value if that value is not -1U. If the value is -1U, it returns false. Feel free to override this directly, instead of runloop(), particularly if you don't intend to change period dynamically.

Reimplemented in CallbackPollThread.

Definition at line 16 of file PollThread.cc.

Referenced by run().

void * PollThread::run (  )  [protected, virtual]

called by launch() once the thread has been set up; when this returns, the thread ends, see runloop()

Default implementation repeatedly calls runloop(), usleep(), and testCancel(). If you override, you should also be sure to call testCancel occasionally in order to support stop() If function returns a value, that value overrides returnValue. If cancel occurs, returnValue is used.

Reimplemented from Thread.

Definition at line 37 of file PollThread.cc.

virtual void PollThread::setTrackPollTime ( bool  countPollTime  )  [virtual]

sets trackPollTime

Definition at line 32 of file PollThread.h.

void PollThread::start (  )  [virtual]

requests that the thread be started, if not already running (you need to create separate instances if you want to run multiple copies)

Reimplemented from Thread.

Definition at line 10 of file PollThread.cc.

Referenced by CallbackPollThread::CallbackPollThread().


Member Data Documentation

TimeET PollThread::delay [protected]

amount of time to delay between call to start() and first call to poll(), or if interrupt occurs after first poll(), amount of time to re-sleep

Definition at line 58 of file PollThread.h.

Referenced by interrupted(), CallbackPollThread::resetPeriod(), and run().

bool PollThread::initialPoll [protected]

set to true after start until after first call to poll has completed

Definition at line 62 of file PollThread.h.

Referenced by interrupted(), run(), and start().

TimeET PollThread::period [protected]

amount of time between calls to poll() -- if zero or negative, no delay will be made between calls (other than a call to testCancel())

Definition at line 59 of file PollThread.h.

Referenced by interrupted(), poll(), CallbackPollThread::resetPeriod(), and run().

TimeET PollThread::startTime [protected]

the time at which start() was called or the current period began

Definition at line 60 of file PollThread.h.

Referenced by interrupted(), run(), and start().

bool PollThread::trackPollTime [protected]

if true, the time spent in poll() is subtracted from the next sleep time so frequency is fixed; if false, period is added onto whatever time poll() takes

Definition at line 61 of file PollThread.h.

Referenced by getTrackPollTime(), run(), and setTrackPollTime().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:14 2016 by Doxygen 1.6.3