Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnMomeWriterFifo< Type > Class Template Reference

emulate a Fifo over a shared memory whose coherance isn't sequential, on the writer node More...

#include <PsnMomeWriterFifo.h>

Inheritance diagram for PsnMomeWriterFifo< Type >:

Inheritance graph
[legend]
Collaboration diagram for PsnMomeWriterFifo< Type >:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnMomeWriterFifo (const int, PsnRelaxedMemoryManager *myMemory)
 PsnMomeWriterFifo (void *fifoAddress, const unsigned int size)
virtual ~PsnMomeWriterFifo ()
virtual void set (const Type &val, const PsDate &date)
 add a value to the fifo

virtual unsigned int getNumberOfPresentValues (int maxCherche=-1) const
 get the number of values in the fifo

virtual void setInPlace (const Type &val, const PsDate &date)
 make an allready copied value available for reading

virtual Type & getNextPlaceHolder ()
 get a reference to the next place that will be used to store a value

virtual void clear ()
 clear the fifo

virtual void printDebuggingInformation () const
 printDebuggingInformation print any usefull debugging information


Protected Methods

virtual unsigned int findFirstValid () const
 find the index of the first valid value

virtual const PsDategetOldestDateAfter (const int indice) const
 look for the next valid date after index indice.


Detailed Description

template<typename Type>
class PsnMomeWriterFifo< Type >

emulate a Fifo over a shared memory whose coherance isn't sequential, on the writer node

Definition at line 25 of file PsnMomeWriterFifo.h.


Constructor & Destructor Documentation

template<typename Type>
PsnMomeWriterFifo< Type >::PsnMomeWriterFifo const    int,
PsnRelaxedMemoryManager   myMemory
 

Definition at line 51 of file PsnMomeWriterFifo.h.

00052                                                                                              : 
00053    PsnMomeFifo<Type> (size,myMemory) {
00054 

template<typename Type>
PsnMomeWriterFifo< Type >::PsnMomeWriterFifo void *    fifoAddress,
const unsigned int    size
 

Definition at line 59 of file PsnMomeWriterFifo.h.

00060                                                                                        : 
00061    PsnMomeFifo<Type> (fifoAddress,size) {
00062    

template<typename Type>
PsnMomeWriterFifo< Type >::~PsnMomeWriterFifo   [virtual]
 

Definition at line 67 of file PsnMomeWriterFifo.h.

00068                                             {
00069 


Member Function Documentation

template<typename Type>
void PsnMomeWriterFifo< Type >::clear   [virtual]
 

clear the fifo

Implements PsnMomeFifo< Type >.

Definition at line 186 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, and PsnMomeFifo< Type >::_lastValidIndex.

00187                                     {
00188    _dateOfOldestValidValue = (*_tab)[_lastValidIndex].dateValeur ;
00189    (*_tab)[_lastValidIndex].dateValeur -- ;

template<typename Type>
unsigned int PsnMomeWriterFifo< Type >::findFirstValid   const [protected, virtual]
 

find the index of the first valid value

Implements PsnMomeFifo< Type >.

Definition at line 176 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::_lastValidIndex.

Referenced by PsnMomeWriterFifo< Type >::getNumberOfPresentValues().

00177                                                            {
00178 #ifdef _DEBUGATTRIBUTSMOME
00179    cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::findFirstValid ()"<<endl;
00180 #endif
00181    return _lastValidIndex ;

template<typename Type>
Type & PsnMomeWriterFifo< Type >::getNextPlaceHolder   [virtual]
 

get a reference to the next place that will be used to store a value

Implements PsnMomeFifo< Type >.

Definition at line 116 of file PsnMomeWriterFifo.h.

References PsnRelaxedMemoryManager::getWritableQueueIndex().

00118 {
00119    return (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].valeur ;

template<typename Type>
unsigned int PsnMomeWriterFifo< Type >::getNumberOfPresentValues int    maxCherche = -1 const [virtual]
 

get the number of values in the fifo

Parameters:
lookingFor the number of values the caller is looking for. If == -1, get all values, otherwise, once lookingFor values are found, that number is returned

Implements PsnMomeFifo< Type >.

Definition at line 123 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, and PsnMomeWriterFifo< Type >::findFirstValid().

00124                                                                                      {
00125 #ifdef _DEBUGATTRIBUTSMOME
00126    cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::getNumberOfPresentValues("<<maxCherche<<")"<<endl;
00127 #endif
00128    unsigned int nbATrouver ;
00129    if (maxCherche == -1) {
00130       nbATrouver = _fifoSize ;
00131    }
00132    else {
00133       nbATrouver = maxCherche ; 
00134    }
00135    int lookAt = findFirstValid () ;
00136 
00137    unsigned int nbValidFound = 0 ;
00138    unsigned int nbLookedAt = 0 ;
00139 
00140    while ( ( nbValidFound < nbATrouver ) && 
00141            ( nbLookedAt < _fifoSize ) ) {
00142          if ( (*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) nbValidFound++ ;
00143          nbLookedAt++ ;
00144          if (lookAt != 0 ) {
00145             lookAt--;
00146          }
00147          else {
00148             lookAt = _fifoSize -1 ;
00149          }      
00150    } 
00151    return nbValidFound ;

template<typename Type>
const PsDate & PsnMomeWriterFifo< Type >::getOldestDateAfter const int    indice const [protected, virtual]
 

look for the next valid date after index indice.

It will become the date of the oldest valid value

Definition at line 156 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnAbstractFifo< Type >::_fifoSize, PsnMomeFifo< Type >::_tab, and PsDate.

Referenced by PsnMomeWriterFifo< Type >::set(), and PsnMomeWriterFifo< Type >::setInPlace().

00157                                                                        {
00158    //if the assertion isn't valid, the loop might never end
00159    assert ((*_tab)[i].dateValeur >= _dateOfOldestValidValue ) ;
00160 
00161    int lookAt = ( i + 1 ) % _fifoSize ;
00162    int nbValidFound = 0 ;
00163    
00164    if ((*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) nbValidFound++ ;
00165 
00166    while (nbValidFound != 1) {
00167       lookAt = ( lookAt + 1 ) % _fifoSize ;
00168       if ((*_tab)[lookAt].dateValeur >= _dateOfOldestValidValue ) nbValidFound++ ;
00169    }
00170 
00171    return (*_tab) [lookAt].dateValeur ;

template<typename Type>
void PsnMomeWriterFifo< Type >::printDebuggingInformation   const [virtual]
 

printDebuggingInformation print any usefull debugging information

Implements PsnMomeFifo< Type >.

Definition at line 194 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::printDebuggingInformation().

00195                                                               {
00196    cerr<<" PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::printDebuggingInformation () "<<endl;
00197    PsnMomeFifo<Type>::printDebuggingInformation() ;

template<typename Type>
void PsnMomeWriterFifo< Type >::set const Type &    val,
const PsDate   date
[virtual]
 

add a value to the fifo

Implements PsnMomeFifo< Type >.

Definition at line 74 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeFifo< Type >::_tab, PsnMomeWriterFifo< Type >::getOldestDateAfter(), PsnRelaxedMemoryManager::getWritableQueueIndex(), and PsDate.

00075                                                                        {
00076 #ifdef _DEBUGATTRIBUTSMOME
00077    cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::set("<<val<<", "<<date<<")"<<endl;
00078 #endif
00079    PsDate & oldDateAtWrittenIndex ((*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].dateValeur) ;
00080 //     cerr<<"Written at adress : "<<&(*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()]
00081 //         <<" which is page : "<<PsnSharedMemoryManager::whichSharedMemoryManager(_tab)->globalAddressToLocal(&(*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()])/4096+4096
00082 //         <<endl;
00083    (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].valeur = val ;
00084    //assert (oldDateAtWrittenIndex != date) ;
00085    if ( oldDateAtWrittenIndex != date ) {//avoid rechanging 
00086       (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].dateValeur = date ;
00087       _dateOfOldestValidValue = getOldestDateAfter (PsnRelaxedMemoryManager::getWritableQueueIndex()) ;
00088       _lastValidIndex = PsnRelaxedMemoryManager::getWritableQueueIndex() ;
00089       (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].datePlusVieilleValeurValide = _dateOfOldestValidValue ;
00090 
00091    }
00092 #ifdef _DEBUGATTRIBUTSMOME
00093    cerr<<"PsnMomeWriterFifo<"<<typeid(Type).name()<<">::"<<this<<"::set done"<<endl;
00094 #endif

template<typename Type>
void PsnMomeWriterFifo< Type >::setInPlace const Type &    val,
const PsDate   date
[virtual]
 

make an allready copied value available for reading

Implements PsnMomeFifo< Type >.

Definition at line 98 of file PsnMomeWriterFifo.h.

References PsnMomeFifo< Type >::_dateOfOldestValidValue, PsnMomeFifo< Type >::_lastValidIndex, PsnMomeFifo< Type >::_tab, PsnMomeWriterFifo< Type >::getOldestDateAfter(), PsnRelaxedMemoryManager::getWritableQueueIndex(), and PsDate.

00099                                                                                    {
00100 
00101 
00102    PsDate & oldDateAtWrittenIndex ((*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].dateValeur) ;
00103 
00104    assert (&((*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].valeur) == &newValue ) ;
00105 
00106    if ( oldDateAtWrittenIndex != date ) //avoid rechanging 
00107       {
00108          (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].dateValeur = date ;
00109          _dateOfOldestValidValue = getOldestDateAfter (PsnRelaxedMemoryManager::getWritableQueueIndex()) ;
00110          _lastValidIndex = PsnRelaxedMemoryManager::getWritableQueueIndex() ;
00111          (*_tab)[PsnRelaxedMemoryManager::getWritableQueueIndex()].datePlusVieilleValeurValide = _dateOfOldestValidValue ;
00112          
00113       }


The documentation for this class was generated from the following file:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:11 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001