Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Monitor::Utility::Timeout Class Reference

Invokes a callback function on expiration. More...

#include <timeout.h>

Inheritance diagram for Monitor::Utility::Timeout:

Monitor::Utility::Watchable List of all members.

Public Methods

 Timeout (const CallbackBase &newWatch, unsigned newPeriod, const string &newName="")
 Constructor. More...

 Timeout (unsigned newPeriod, const string &newName="")
 Constructor. More...

virtual ~Timeout ()
 Destructor. More...

int operator== (const Timeout &other)
 Equivalence operator. More...

void reset (unsigned newPeriod=0)
 Clock time at which timeout will expire = current clock time + period. More...

int hasExpired () const
int run ()
 If timeout can run (callback and target set, not yet expired) checks time to see if it is now due, if so 'expires' itself. More...

const string & getTimeoutName () const

Private Methods

 Timeout ()
 Default construction is not allowed. More...

 Timeout (const Timeout &)
 Copy construction is not allowed. More...

Timeout & operator= (const Timeout &)
 Assignment is not allowed. More...

virtual int canRun ()
void expire ()
 Invoked when timeout expires. More...


Private Attributes

unsigned period
 Timeout period. More...

clock_t endTime
 Clock time at which timeout is expired, calculated when period is set. More...

string timeoutName
int expiredFlag

Detailed Description

Invokes a callback function on expiration.

Definition at line 53 of file timeout.h.


Constructor & Destructor Documentation

Timeout::Timeout const CallbackBase   newWatch,
unsigned    newPeriod,
const string &    newName = ""
 

Constructor.

On construction timeout adds itself to a singleton list.

Parameters:
newWatch  Watch callback to be invoked on expiration.
newPeriod  Length of timeout in milliseconds.
newName  Optional timeout name for trace output.

Definition at line 47 of file timeout.cpp.

References _USEMYTRACE_.

Referenced by operator=, and Timeout.

Timeout::Timeout unsigned    newPeriod,
const string &    newName = ""
 

Constructor.

Parameters:
newPeriod  Length of timeout in milliseconds.
newName  Optional timeout name for trace output.

Definition at line 69 of file timeout.cpp.

References _USEMYTRACE_, reset, and timeoutName.

Timeout::~Timeout   [virtual]
 

Destructor.

On destruction timeout removes itself from a singleton list.

Definition at line 87 of file timeout.cpp.

References _USEMYTRACE_, and timeoutName.

Monitor::Utility::Timeout::Timeout   [inline, private]
 

Default construction is not allowed.

Definition at line 135 of file timeout.h.

Monitor::Utility::Timeout::Timeout const Timeout &    [inline, private]
 

Copy construction is not allowed.

Definition at line 140 of file timeout.h.

References Timeout.


Member Function Documentation

int Timeout::canRun   [private, virtual]
 

Returns:
!0 ('true') if timeout can run, otherwise 0 ('false').

Definition at line 179 of file timeout.cpp.

References endTime, and expiredFlag.

Referenced by run.

void Timeout::expire   [private]
 

Invoked when timeout expires.

Definition at line 188 of file timeout.cpp.

References _USEMYTRACE_, expiredFlag, timeoutName, and Monitor::Utility::Watchable::updated.

Referenced by run.

const string & Timeout::getTimeoutName   const
 

Returns:
Name of timeout.

Definition at line 171 of file timeout.cpp.

References timeoutName.

int Timeout::hasExpired   const
 

Returns:
!0 ('true') if timeout has expired, otherwise 0 ('false').

Definition at line 141 of file timeout.cpp.

References expiredFlag.

Timeout& Monitor::Utility::Timeout::operator= const Timeout &    [inline, private]
 

Assignment is not allowed.

Definition at line 147 of file timeout.h.

References Timeout.

int Timeout::operator== const Timeout &    other
 

Equivalence operator.

Definition at line 102 of file timeout.cpp.

void Timeout::reset unsigned    newPeriod = 0
 

Clock time at which timeout will expire = current clock time + period.

Parameters:
newPeriod  Length of timeout in milliseconds, 0 == reuse original period.

Definition at line 110 of file timeout.cpp.

References _USEMYTRACE_, endTime, expiredFlag, period, and timeoutName.

Referenced by Timeout.

int Timeout::run  
 

If timeout can run (callback and target set, not yet expired) checks time to see if it is now due, if so 'expires' itself.

Returns:
!0 ('true') if timeout has expired, otherwise 0 ('false').

Definition at line 149 of file timeout.cpp.

References canRun, endTime, and expire.


Member Data Documentation

clock_t Monitor::Utility::Timeout::endTime [private]
 

Clock time at which timeout is expired, calculated when period is set.

Definition at line 130 of file timeout.h.

Referenced by canRun, reset, and run.

int Monitor::Utility::Timeout::expiredFlag [private]
 

Definition at line 162 of file timeout.h.

Referenced by canRun, expire, hasExpired, and reset.

unsigned Monitor::Utility::Timeout::period [private]
 

Timeout period.

Definition at line 125 of file timeout.h.

Referenced by reset.

string Monitor::Utility::Timeout::timeoutName [private]
 

Definition at line 161 of file timeout.h.

Referenced by expire, getTimeoutName, reset, Timeout, and ~Timeout.


Generated on Wed Oct 29 20:51:59 2003 for Utility BC Common by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002