TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, > Class Template Reference

TAO_ESF_Copy_On_Write. More...

#include <ESF_Copy_On_Write.h>

Inheritance diagram for TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >:

Inheritance graph
[legend]
Collaboration diagram for TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_ESF_Copy_On_Write_Read_Guard<
COLLECTION, ITERATOR, ACE_SYNCH_MUTEX_T
Read_Guard
 Constructor.

typedef TAO_ESF_Copy_On_Write_Write_Guard<
COLLECTION, ITERATOR, ACE_SYNCH_USE
Write_Guard

Public Member Functions

 TAO_ESF_Copy_On_Write (void)
 ~TAO_ESF_Copy_On_Write (void)
 Destructor.

virtual void for_each (TAO_ESF_Worker< PROXY > *worker ACE_ENV_ARG_DECL)
virtual void connected (PROXY *proxy ACE_ENV_ARG_DECL)
virtual void reconnected (PROXY *proxy ACE_ENV_ARG_DECL)
virtual void disconnected (PROXY *proxy ACE_ENV_ARG_DECL)
virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL)

Private Types

typedef TAO_ESF_Copy_On_Write_Collection<
COLLECTION, ITERATOR > 
Collection

Private Attributes

ACE_SYNCH_MUTEX_T mutex_
 A mutex to serialize access to the collection pointer.

int pending_writes_
 Number of pending writes.

int writing_
ACE_SYNCH_CONDITION_T cond_
 A condition variable to wait to synchronize multiple writers.

Collectioncollection_
 The collection, with reference counting added.


Detailed Description

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL>
class TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >

TAO_ESF_Copy_On_Write.

Implement the Copy_On_Write protocol The class is parametric on the kind of collection and locking mechanism used.

Definition at line 123 of file ESF_Copy_On_Write.h.


Member Typedef Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
typedef TAO_ESF_Copy_On_Write_Collection<COLLECTION,ITERATOR> TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Collection [private]
 

Definition at line 146 of file ESF_Copy_On_Write.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
typedef TAO_ESF_Copy_On_Write_Read_Guard<COLLECTION,ITERATOR,ACE_SYNCH_MUTEX_T> TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Read_Guard
 

Constructor.

Definition at line 127 of file ESF_Copy_On_Write.h.

Referenced by TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::for_each().

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
typedef TAO_ESF_Copy_On_Write_Write_Guard<COLLECTION,ITERATOR,ACE_SYNCH_USE> TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Write_Guard
 

Definition at line 128 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(), and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::shutdown().


Constructor & Destructor Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::TAO_ESF_Copy_On_Write void   ) 
 

Definition at line 47 of file ESF_Copy_On_Write.cpp.

References ACE_NEW.

00048       :  pending_writes_ (0),
00049          writing_ (0),
00050          cond_ (mutex_)
00051 {
00052   ACE_NEW (this->collection_, Collection);
00053 }

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

Destructor.

Definition at line 57 of file ESF_Copy_On_Write.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX_T, and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::pending_writes_.

00058 {
00059   ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->mutex_);
00060 
00061   while (this->pending_writes_ != 0)
00062     this->cond_.wait ();
00063 
00064   this->collection_->_decr_refcnt ();
00065   this->collection_ = 0;
00066 }


Member Function Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::connected PROXY *proxy  ACE_ENV_ARG_DECL  )  [virtual]
 

Definition at line 87 of file ESF_Copy_On_Write.cpp.

References ACE_ENV_ARG_PARAMETER, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy, and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Write_Guard.

00089 {
00090   Write_Guard ace_mon (this->mutex_,
00091                        this->cond_,
00092                        this->pending_writes_,
00093                        this->writing_,
00094                        this->collection_);
00095 
00096   proxy->_incr_refcnt ();
00097   ace_mon.copy->collection.connected (proxy ACE_ENV_ARG_PARAMETER);
00098 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::disconnected PROXY *proxy  ACE_ENV_ARG_DECL  )  [virtual]
 

Definition at line 117 of file ESF_Copy_On_Write.cpp.

References ACE_ENV_ARG_PARAMETER, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy, and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Write_Guard.

00119 {
00120   Write_Guard ace_mon (this->mutex_,
00121                        this->cond_,
00122                        this->pending_writes_,
00123                        this->writing_,
00124                        this->collection_);
00125 
00126   ace_mon.copy->collection.disconnected (proxy ACE_ENV_ARG_PARAMETER);
00127 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::for_each TAO_ESF_Worker< PROXY > *worker  ACE_ENV_ARG_DECL  )  [virtual]
 

Definition at line 70 of file ESF_Copy_On_Write.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, TAO_ESF_Copy_On_Write_Read_Guard< COLLECTION, ITERATOR, ACE_LOCK >::collection, and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Read_Guard.

00072 {
00073   Read_Guard ace_mon (this->mutex_,
00074                       this->collection_);
00075 
00076   worker->set_size(ace_mon.collection->collection.size());
00077   ITERATOR end = ace_mon.collection->collection.end ();
00078   for (ITERATOR i = ace_mon.collection->collection.begin (); i != end; ++i)
00079     {
00080       worker->work (*i ACE_ENV_ARG_PARAMETER);
00081       ACE_CHECK;
00082     }
00083 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::reconnected PROXY *proxy  ACE_ENV_ARG_DECL  )  [virtual]
 

Definition at line 102 of file ESF_Copy_On_Write.cpp.

References ACE_ENV_ARG_PARAMETER, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy, and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Write_Guard.

00104 {
00105   Write_Guard ace_mon (this->mutex_,
00106                        this->cond_,
00107                        this->pending_writes_,
00108                        this->writing_,
00109                        this->collection_);
00110 
00111   proxy->_incr_refcnt ();
00112   ace_mon.copy->collection.reconnected (proxy ACE_ENV_ARG_PARAMETER);
00113 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::shutdown ACE_ENV_SINGLE_ARG_DECL   )  [virtual]
 

Definition at line 131 of file ESF_Copy_On_Write.cpp.

References ACE_ENV_SINGLE_ARG_PARAMETER, TAO_ESF_Copy_On_Write_Write_Guard< COLLECTION, ITERATOR, >::copy, and TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::Write_Guard.

00132 {
00133   // We need to perform a copy to follow the protocol.
00134   Write_Guard ace_mon (this->mutex_,
00135                        this->cond_,
00136                        this->pending_writes_,
00137                        this->writing_,
00138                        this->collection_);
00139 
00140   ace_mon.copy->collection.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
00141 }


Member Data Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
Collection* TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::collection_ [private]
 

The collection, with reference counting added.

Definition at line 165 of file ESF_Copy_On_Write.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
ACE_SYNCH_CONDITION_T TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::cond_ [private]
 

A condition variable to wait to synchronize multiple writers.

Definition at line 162 of file ESF_Copy_On_Write.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
ACE_SYNCH_MUTEX_T TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::mutex_ [private]
 

A mutex to serialize access to the collection pointer.

Definition at line 149 of file ESF_Copy_On_Write.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
int TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::pending_writes_ [private]
 

Number of pending writes.

Definition at line 152 of file ESF_Copy_On_Write.h.

Referenced by TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::~TAO_ESF_Copy_On_Write().

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
int TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::writing_ [private]
 

If non-zero then a thread is changing the collection. Many threads can use the collection simulatenously, but only one change it.

Definition at line 159 of file ESF_Copy_On_Write.h.


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