#include <ESF_Copy_On_Write.h>
Inheritance diagram for TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >:
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. | |
Collection * | collection_ |
The collection, with reference counting added. |
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.
|
Definition at line 146 of file ESF_Copy_On_Write.h. |
|
Constructor.
Definition at line 127 of file ESF_Copy_On_Write.h. Referenced by TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, >::for_each(). |
|
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
The collection, with reference counting added.
Definition at line 165 of file ESF_Copy_On_Write.h. |
|
A condition variable to wait to synchronize multiple writers.
Definition at line 162 of file ESF_Copy_On_Write.h. |
|
A mutex to serialize access to the collection pointer.
Definition at line 149 of file ESF_Copy_On_Write.h. |
|
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(). |
|
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. |