dlr::utilities::FrequencyGoverner Class Reference

The FrequencyGoverner class allows you to conveniently throttle a loop so that it runs at a specific speed. More...

#include <frequencyGoverner.h>

List of all members.

Public Member Functions

 FrequencyGoverner (double frequency, double duration)
 The constructor initializes the FrequencyGoverner and starts the internal timer.
 ~FrequencyGoverner ()
 The destructor destroys the FrequencyGoverner instance and deletes any file created by the constructor, thereby releasing the lock.
bool isFinished ()
 This method reports whether or not the specified period (from constructor argument "duration") has elapsed.
void sleepIfNecessary ()


Detailed Description

The FrequencyGoverner class allows you to conveniently throttle a loop so that it runs at a specific speed.

Here's an example of how it might be used:

   double frequency = 30.0; // Hz.
   double duration = 10.0;  // Seconds.
   FrequencyGoverner governer(frequency, duration);
   while(!governer.isFinished()) {
     // Do something.
     // [..]
     governer.sleepIfNecessary();
   }

Definition at line 40 of file frequencyGoverner.h.


Constructor & Destructor Documentation

dlr::utilities::FrequencyGoverner::FrequencyGoverner ( double  frequency,
double  duration 
) [inline]

The constructor initializes the FrequencyGoverner and starts the internal timer.

Parameters:
frequency This argument specifies how fast you'd like the loop to run. Setting this argument to zero indicates no throttling of loop speed.
duration This argument specifies how long you'd like the loop to run. Setting this argument to zero indicates no timeout.

Definition at line 55 of file frequencyGoverner.h.

dlr::utilities::FrequencyGoverner::~FrequencyGoverner (  )  [inline]

The destructor destroys the FrequencyGoverner instance and deletes any file created by the constructor, thereby releasing the lock.

Definition at line 64 of file frequencyGoverner.h.


Member Function Documentation

bool dlr::utilities::FrequencyGoverner::isFinished (  )  [inline]

This method reports whether or not the specified period (from constructor argument "duration") has elapsed.

Returns:
The return value is true if the FrequencyGoverner was instantiated more than "duration" seconds ago, false otherwise.

Definition at line 75 of file frequencyGoverner.h.

References dlr::portability::getCurrentTime().


The documentation for this class was generated from the following file:
Generated on Mon Jul 9 20:34:22 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2