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>

Collaboration diagram for TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >:

Collaboration graph
[legend]
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 137 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, >::collection, TAO_ESF_Copy_On_Write_Collection< COLLECTION, ITERATOR >::collection, 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.

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

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 179 of file ESF_Copy_On_Write.cpp.

References TAO_ESF_Copy_On_Write_Collection< COLLECTION, ITERATOR >::_decr_refcnt(), ACE_GUARD, ACE_SYNCH_MUTEX_T, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::collection, 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.

00180 {
00181   Collection *tmp = 0;
00182   {
00183     ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->mutex);
00184 
00185     tmp = this->collection;
00186     this->collection = this->copy;
00187     this->writing_flag = 0;
00188     this->pending_writes--;
00189 
00190     this->cond.signal ();
00191   }
00192   // Delete outside the mutex, because it may take a long time.
00193   tmp->_decr_refcnt ();
00194 }


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.

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 >
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 Tue Feb 2 17:43:50 2010 for TAO_ESF by  doxygen 1.4.7