GNE  0.75.0
GNE::Counter Class Reference

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

#include <Counter.h>

Inheritance diagram for GNE::Counter:
GNE::TimerCallback

Public Types

typedef SmartPtr< Countersptr
typedef WeakPtr< Counterwptr
- Public Types inherited from GNE::TimerCallback
typedef SmartPtr< TimerCallbacksptr
typedef WeakPtr< TimerCallbackwptr

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
newCountthe 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: