GNE::Counter Class Reference
[Threading API]

An implementation of a TimerCallback that provides a simple counter. More...

#include <Counter.h>

Inheritance diagram for GNE::Counter:

Inheritance graph
[legend]
Collaboration diagram for GNE::Counter:

Collaboration graph
[legend]
List of all members.

Public Types

typedef SmartPtr< Countersptr
typedef WeakPtr< Counterwptr

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

static 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 Tue Sep 5 23:47:47 2006 for GNE by  doxygen 1.4.7