Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE::Counter Class Reference
[Threading API]

#include <Counter.h>

Inheritance diagram for GNE::Counter:

GNE::TimerCallback List of all members.

Public Types

typedef SmartPtr< Counter > sptr
typedef WeakPtr< Counter > wptr

Public Member Functions

virtual ~Counter ()
 Destructor.

void timerCallback ()
 The callback function that the Timer calls.

int getCount ()
 Returns the current count of this Counter.

void setCount (int newCount)
 Sets the current count to newCount.

void adjustCount (int val)
 Adjusts the counter's value by adding val to the current count.

void waitAndDecrement ()
 This method blocks until the count is greater than zero.


Static Public Member Functions

sptr create ()
 Create a Counter.


Detailed Description

An implementation of a TimerCallback that provides a simple counter. All of the functions in this class are thread-safe so that multiple threads can be accessing the Counter at the same time.


Member Function Documentation

void GNE::Counter::adjustCount int  val  ) 
 

Adjusts the counter's value by adding val to the current count.

This means that negative numbers will subtract from the current count.

Counter::sptr GNE::Counter::create  )  [static]
 

Create a Counter.

Pass this Counter into a Timer class to use it.

See also:
TimerCallback

void GNE::Counter::setCount int  newCount  ) 
 

Sets the current count to newCount.

Parameters:
newCount the new value for the Counter

void GNE::Counter::timerCallback  )  [virtual]
 

The callback function that the Timer calls.

You should not call this function directly.

Implements GNE::TimerCallback.

void GNE::Counter::waitAndDecrement  ) 
 

This method blocks until the count is greater than zero.

If the count is already greater than zero it returns immediately. In either case, the value of the counter is decremented.


The documentation for this class was generated from the following files:
Generated on Fri Aug 22 13:40:06 2003 for GNE by doxygen1.3