TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, > Class Template Reference

TAO_ESF_Copy_On_Write_Write_Guard. More...

#include <ESF_Copy_On_Write.h>

List of all members.

Public Types

typedef TAO_ESF_Copy_On_Write_Collection<
COLLECTION, ITERATOR > 
Collection
 Constructor.


Public Member Functions

 TAO_ESF_Copy_On_Write_Write_Guard (ACE_SYNCH_MUTEX_T &mutex, ACE_SYNCH_CONDITION_T &cond, int &pending_writes, int &writing_flag, Collection *&collection)
 ~TAO_ESF_Copy_On_Write_Write_Guard (void)
 Destructor.


Public Attributes

Collectioncopy

Private Attributes

ACE_SYNCH_MUTEX_Tmutex
ACE_SYNCH_CONDITION_Tcond
int & pending_writes
int & writing_flag
Collection *& collection


Detailed Description

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL>
class TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >

TAO_ESF_Copy_On_Write_Write_Guard.

This helper class atomically increments the reference count of a TAO_ESF_Copy_On_Write_Collection and reads the current collection in the Copy_On_Write class.

Definition at line 87 of file ESF_Copy_On_Write.h.


Member Typedef Documentation

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
typedef TAO_ESF_Copy_On_Write_Collection<COLLECTION,ITERATOR> TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::Collection
 

Constructor.

Definition at line 91 of file ESF_Copy_On_Write.h.


Constructor & Destructor Documentation

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::TAO_ESF_Copy_On_Write_Write_Guard ACE_SYNCH_MUTEX_T mutex,
ACE_SYNCH_CONDITION_T cond,
int &  pending_writes,
int &  writing_flag,
Collection *&  collection
 

Definition at line 145 of file ESF_Copy_On_Write.cpp.

References ACE_GUARD, ACE_NEW, ACE_SYNCH_MUTEX_T, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::cond, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::pending_writes, and TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::writing_flag.

00150       :  copy (0),
00151          mutex (m),
00152          cond (c),
00153          pending_writes (p),
00154          writing_flag (w),
00155          collection (cr)
00156 {
00157   {
00158     ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->mutex);
00159 
00160     this->pending_writes++;
00161 
00162     while (this->writing_flag != 0)
00163       this->cond.wait ();
00164 
00165     this->writing_flag = 1;
00166   }
00167 
00168   // Copy outside the mutex, because it may take a long time.
00169   // Nobody can change it, because it is protected by the
00170   // writing_flag.
00171 
00172   // First initialize it (with the correct reference count
00173   ACE_NEW (this->copy, Collection);
00174   // Copy the contents
00175   this->copy->collection = this->collection->collection;
00176 
00177   // Increase the reference counts
00178   ITERATOR end = this->copy->collection.end ();
00179   for (ITERATOR i = this->copy->collection.begin (); i != end; ++i)
00180     {
00181       (*i)->_incr_refcnt ();
00182     }
00183 }

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::~TAO_ESF_Copy_On_Write_Write_Guard void   ) 
 

Destructor.

Definition at line 187 of file ESF_Copy_On_Write.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX_T, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::cond, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::pending_writes, and TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::writing_flag.

00188 {
00189   Collection *tmp = 0;
00190   {
00191     ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->mutex);
00192 
00193     tmp = this->collection;
00194     this->collection = this->copy;
00195     this->writing_flag = 0;
00196     this->pending_writes--;
00197 
00198     this->cond.signal ();
00199   }
00200   // Delete outside the mutex, because it may take a long time.
00201   tmp->_decr_refcnt ();
00202 }


Member Data Documentation

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
Collection*& TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::collection [private]
 

Definition at line 108 of file ESF_Copy_On_Write.h.

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
ACE_SYNCH_CONDITION_T& TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::cond [private]
 

Definition at line 105 of file ESF_Copy_On_Write.h.

Referenced by TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::TAO_ESF_Copy_On_Write_Write_Guard(), and TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::~TAO_ESF_Copy_On_Write_Write_Guard().

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
Collection* TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy
 

Definition at line 101 of file ESF_Copy_On_Write.h.

Referenced by TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::connected(), TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::disconnected(), TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::reconnected(), TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::shutdown(), TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::TAO_ESF_Copy_On_Write_Write_Guard(), and TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::~TAO_ESF_Copy_On_Write_Write_Guard().

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
ACE_SYNCH_MUTEX_T& TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::mutex [private]
 

Definition at line 104 of file ESF_Copy_On_Write.h.

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
int& TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::pending_writes [private]
 

Definition at line 106 of file ESF_Copy_On_Write.h.

Referenced by TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::TAO_ESF_Copy_On_Write_Write_Guard(), and TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::~TAO_ESF_Copy_On_Write_Write_Guard().

template<class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
int& TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::writing_flag [private]
 

Definition at line 107 of file ESF_Copy_On_Write.h.

Referenced by TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::TAO_ESF_Copy_On_Write_Write_Guard(), and TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::~TAO_ESF_Copy_On_Write_Write_Guard().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:08:51 2006 for TAO_ESF by doxygen 1.3.6