TAO_ESF_Copy_On_Write. More...
#include <ESF_Copy_On_Write.h>
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) |
virtual void | connected (PROXY *proxy) |
virtual void | reconnected (PROXY *proxy) |
virtual void | disconnected (PROXY *proxy) |
Remove an element from the collection. | |
virtual void | shutdown (void) |
The EC is shutting down, must release all the elements. | |
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.
typedef TAO_ESF_Copy_On_Write_Collection<COLLECTION,ITERATOR> TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::Collection [private] |
Definition at line 142 of file ESF_Copy_On_Write.h.
typedef TAO_ESF_Copy_On_Write_Read_Guard<COLLECTION,ITERATOR,ACE_SYNCH_MUTEX_T> TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::Read_Guard |
Constructor.
Definition at line 127 of file ESF_Copy_On_Write.h.
typedef TAO_ESF_Copy_On_Write_Write_Guard<COLLECTION,ITERATOR,ACE_SYNCH_USE> TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::Write_Guard |
Definition at line 128 of file ESF_Copy_On_Write.h.
TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::TAO_ESF_Copy_On_Write | ( | void | ) |
Definition at line 46 of file ESF_Copy_On_Write.cpp.
: pending_writes_ (0), writing_ (0), cond_ (mutex_) { ACE_NEW (this->collection_, Collection); }
TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::~TAO_ESF_Copy_On_Write | ( | void | ) |
Destructor.
Definition at line 56 of file ESF_Copy_On_Write.cpp.
{ ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->mutex_); while (this->pending_writes_ != 0) this->cond_.wait (); this->collection_->_decr_refcnt (); this->collection_ = 0; }
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::connected | ( | PROXY * | proxy | ) | [virtual] |
Insert a new element into the collection. The collection assumes ownership of the element.
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 84 of file ESF_Copy_On_Write.cpp.
{ Write_Guard ace_mon (this->mutex_, this->cond_, this->pending_writes_, this->writing_, this->collection_); proxy->_incr_refcnt (); ace_mon.copy->collection.connected (proxy); }
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::disconnected | ( | PROXY * | proxy | ) | [virtual] |
Remove an element from the collection.
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 112 of file ESF_Copy_On_Write.cpp.
{ Write_Guard ace_mon (this->mutex_, this->cond_, this->pending_writes_, this->writing_, this->collection_); ace_mon.copy->collection.disconnected (proxy); }
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::for_each | ( | TAO_ESF_Worker< PROXY > * | worker | ) | [virtual] |
Iterate over the collection and invoke worker->work() for each member of the collection. This encapsulates
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 69 of file ESF_Copy_On_Write.cpp.
{ Read_Guard ace_mon (this->mutex_, this->collection_); worker->set_size(ace_mon.collection->collection.size()); ITERATOR end = ace_mon.collection->collection.end (); for (ITERATOR i = ace_mon.collection->collection.begin (); i != end; ++i) { worker->work (*i); } }
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::reconnected | ( | PROXY * | proxy | ) | [virtual] |
Insert an element into the collection. No errors can be raised if the element is already present. The collection assumes ownership, i.e. must invoke <proxy->_decr_refcnt()> if the element is already present in the collection.
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 98 of file ESF_Copy_On_Write.cpp.
{ Write_Guard ace_mon (this->mutex_, this->cond_, this->pending_writes_, this->writing_, this->collection_); proxy->_incr_refcnt (); ace_mon.copy->collection.reconnected (proxy); }
void TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::shutdown | ( | void | ) | [virtual] |
The EC is shutting down, must release all the elements.
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 124 of file ESF_Copy_On_Write.cpp.
{ // We need to perform a copy to follow the protocol. Write_Guard ace_mon (this->mutex_, this->cond_, this->pending_writes_, this->writing_, this->collection_); ace_mon.copy->collection.shutdown (); }
Collection* TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::collection_ [private] |
The collection, with reference counting added.
Definition at line 161 of file ESF_Copy_On_Write.h.
ACE_SYNCH_CONDITION_T TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::cond_ [private] |
A condition variable to wait to synchronize multiple writers.
Definition at line 158 of file ESF_Copy_On_Write.h.
ACE_SYNCH_MUTEX_T TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::mutex_ [private] |
A mutex to serialize access to the collection pointer.
Definition at line 145 of file ESF_Copy_On_Write.h.
int TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::pending_writes_ [private] |
Number of pending writes.
Definition at line 148 of file ESF_Copy_On_Write.h.
int TAO_ESF_Copy_On_Write< PROXY, COLLECTION, ITERATOR, ACE_SYNCH_DECL >::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 155 of file ESF_Copy_On_Write.h.