NLMISC::CUnfairSynchronized< T > Class Template Reference

#include <mutex.h>


Detailed Description

template<class T>
class NLMISC::CUnfairSynchronized< T >

This class ensure that the Value is accessed by only one thread. First you have to create a CSynchronized class with you type. Then, if a thread want to modify or do anything on it, you create a CAccessor in a sub scope. You can modify the value of the CUnfairSynchronized using the value() function until the end of the scope. So you have to put the smaller scope as you can.

Internally, this class uses a CUnfairMutex object (see CUnfairMutex for programming considerations).

// the value that you want to be thread safe. CUnfairSynchronized<int> val; { // create a new scope for the access // get an access to the value CUnfairSynchronized<int>::CAccessor acces(&val); // now, you have a thread safe access until the end of the scope, so you can do whatever you want. for example, change the value acces.value () = 10; } // end of the access *
Author:
Vianney Lecroart

Nevrax France

Date:
2000

Definition at line 587 of file mutex.h.

Public Member Functions

 CUnfairSynchronized (const std::string &name)

Private Attributes

volatile CUnfairMutex _Mutex
 The mutex of the synchronized value.

volatile T _Value
 The synchronized value.


Friends

class CUnfairSynchronized::CAccessor


Constructor & Destructor Documentation

template<class T>
NLMISC::CUnfairSynchronized< T >::CUnfairSynchronized const std::string &  name  )  [inline]
 

Definition at line 591 of file mutex.h.

00591 : _Mutex(name) { }


Friends And Related Function Documentation

template<class T>
friend class CUnfairSynchronized::CAccessor [friend]
 

Definition at line 623 of file mutex.h.


Field Documentation

template<class T>
volatile CUnfairMutex NLMISC::CUnfairSynchronized< T >::_Mutex [private]
 

The mutex of the synchronized value.

Definition at line 626 of file mutex.h.

template<class T>
volatile T NLMISC::CUnfairSynchronized< T >::_Value [private]
 

The synchronized value.

Definition at line 629 of file mutex.h.


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 13:39:21 2004 for NeL by doxygen 1.3.6