Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

GuardedVariable< T > Class Template Reference

#include <GuardedVariable.hpp>

Collaboration diagram for GuardedVariable< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GuardedVariable (T initialValue=0)
inc ()
dec ()
value ()
void set (T newValue)
void reset ()

Private Attributes

volatile T variable
pthread_mutex_t lock

Detailed Description

template<typename T>
class GuardedVariable< T >

Guarded variable - protects a number variable from race conditions.

A guarded variable contais a templatized number variable. All access to this variable is synchronized by the use of a lock.

Author:
Andrei Goldchleger
Date:
November, 2003


Constructor & Destructor Documentation

template<typename T>
GuardedVariable< T >::GuardedVariable initialValue = 0  )  [inline]
 

Constructs a GuardedVariable object.

Parameters:
initialValue - initial values of the guarded variable (Default: 0)


Member Function Documentation

template<typename T>
T GuardedVariable< T >::dec  )  [inline]
 

Decrements the guarded variable.

Returns:
the variable value PRIOR to the decrementation

template<typename T>
T GuardedVariable< T >::inc  )  [inline]
 

Increments the guarded variable.

Returns:
the variable value PRIOR to the incrementation

template<typename T>
void GuardedVariable< T >::reset  )  [inline]
 

Reset the guarded variable.

template<typename T>
void GuardedVariable< T >::set newValue  )  [inline]
 

Sets the guarded variable to a new value

Parameters:
newValue - new value of the guarded variable.

template<typename T>
T GuardedVariable< T >::value  )  [inline]
 

Returns the value of the guarded variable.


Member Data Documentation

template<typename T>
pthread_mutex_t GuardedVariable< T >::lock [private]
 

lock to prevent race conditions

template<typename T>
volatile T GuardedVariable< T >::variable [private]
 

The variable to be protected


The documentation for this class was generated from the following file:
Generated on Mon Sep 6 16:13:16 2004 by doxygen 1.3.3