NLMISC::CReaderWriter Class Reference

#include <reader_writer.h>


Detailed Description

This class allows a reader/writer ressource usage policy.
Author:
Benjamin Legros

Nevrax France

Date:
2001

Definition at line 40 of file reader_writer.h.

Public Member Functions

 CReaderWriter ()
void enterReader ()
void enterWriter ()
void leaveReader ()
void leaveWriter ()
 ~CReaderWriter ()

Private Attributes

volatile CMutex _Fairness
volatile sint _ReadersLevel
volatile CMutex _ReadersMutex
volatile CMutex _RWMutex


Constructor & Destructor Documentation

NLMISC::CReaderWriter::CReaderWriter  ) 
 

Definition at line 32 of file reader_writer.cpp.

References _ReadersLevel.

00033 {
00034         _ReadersLevel = 0;
00035 }

NLMISC::CReaderWriter::~CReaderWriter  ) 
 

Definition at line 37 of file reader_writer.cpp.

00038 {
00039         // here some checks to avoid a reader/writer still working while we flush the mutexes...
00040 }


Member Function Documentation

void NLMISC::CReaderWriter::enterReader  )  [inline]
 

Definition at line 54 of file reader_writer.h.

References _Fairness, _ReadersLevel, _ReadersMutex, and _RWMutex.

00055         {
00056                 const_cast<CMutex&>(_Fairness).enter();
00057                 const_cast<CMutex&>(_ReadersMutex).enter();
00058                 ++_ReadersLevel;
00059                 if (_ReadersLevel == 1)
00060                         const_cast<CMutex&>(_RWMutex).enter();
00061                 const_cast<CMutex&>(_ReadersMutex).leave();
00062                 const_cast<CMutex&>(_Fairness).leave();
00063         }

void NLMISC::CReaderWriter::enterWriter  )  [inline]
 

Definition at line 74 of file reader_writer.h.

References _Fairness, and _RWMutex.

00075         {
00076                 const_cast<CMutex&>(_Fairness).enter();
00077                 const_cast<CMutex&>(_RWMutex).enter();
00078                 const_cast<CMutex&>(_Fairness).leave();
00079         }

void NLMISC::CReaderWriter::leaveReader  )  [inline]
 

Definition at line 65 of file reader_writer.h.

References _ReadersLevel, _ReadersMutex, and _RWMutex.

00066         {
00067                 const_cast<CMutex&>(_ReadersMutex).enter();
00068                 --_ReadersLevel;
00069                 if (_ReadersLevel == 0)
00070                         const_cast<CMutex&>(_RWMutex).leave();
00071                 const_cast<CMutex&>(_ReadersMutex).leave();
00072         }

void NLMISC::CReaderWriter::leaveWriter  )  [inline]
 

Definition at line 81 of file reader_writer.h.

References _RWMutex.

00082         {
00083                 const_cast<CMutex&>(_RWMutex).leave();
00084         }


Field Documentation

volatile CMutex NLMISC::CReaderWriter::_Fairness [private]
 

Definition at line 44 of file reader_writer.h.

Referenced by enterReader(), and enterWriter().

volatile sint NLMISC::CReaderWriter::_ReadersLevel [private]
 

Definition at line 47 of file reader_writer.h.

Referenced by CReaderWriter(), enterReader(), and leaveReader().

volatile CMutex NLMISC::CReaderWriter::_ReadersMutex [private]
 

Definition at line 45 of file reader_writer.h.

Referenced by enterReader(), and leaveReader().

volatile CMutex NLMISC::CReaderWriter::_RWMutex [private]
 

Definition at line 46 of file reader_writer.h.

Referenced by enterReader(), enterWriter(), leaveReader(), and leaveWriter().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:31:11 2004 for NeL by doxygen 1.3.6