#include <ESF_Copy_On_Write.h>
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 | |
Collection * | copy |
Private Attributes | |
ACE_SYNCH_MUTEX_T & | mutex |
ACE_SYNCH_CONDITION_T & | cond |
int & | pending_writes |
int & | writing_flag |
Collection *& | collection |
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.
|
Constructor.
Definition at line 91 of file ESF_Copy_On_Write.h. |
|
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 } |
|
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 } |
|
Definition at line 108 of file ESF_Copy_On_Write.h. |
|
|
|
Definition at line 104 of file ESF_Copy_On_Write.h. |
|
|