#include <Counter.h>
Inheritance diagram for GNE::Counter:
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 | |
static sptr | create () |
Create a Counter. |
All of the functions in this class are thread-safe so that multiple threads can be accessing the Counter at the same time.
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] |
void GNE::Counter::setCount | ( | int | newCount | ) |
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.