#include <ESF_Delayed_Changes.h>
Inheritance diagram for TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >:
This class implements the Delayed Operations protocol to solve the concurrency challenges outlined in the documentation of TAO_ESF_Proxy_Collection. In short the class delays changes by putting them on an "operation queue", the operations are stored as command objects in this queue and executed once the system is quiescent (i.e. no threads are iterating over the collection). The algorithm implemented so far is:
Definition at line 88 of file ESF_Delayed_Changes.h.
typedef TAO_ESF_Busy_Lock_Adapter<TAO_ESF_Delayed_Changes<PROXY,COLLECTION,ITERATOR,ACE_SYNCH_USE> > TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::Busy_Lock [private] |
Definition at line 118 of file ESF_Delayed_Changes.h.
typedef TAO_ESF_Connected_Command<TAO_ESF_Delayed_Changes<PROXY,COLLECTION,ITERATOR,ACE_SYNCH_USE>,PROXY> TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::Connected_Command |
Definition at line 103 of file ESF_Delayed_Changes.h.
typedef TAO_ESF_Disconnected_Command<TAO_ESF_Delayed_Changes<PROXY,COLLECTION,ITERATOR,ACE_SYNCH_USE>,PROXY> TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::Disconnected_Command |
Definition at line 105 of file ESF_Delayed_Changes.h.
typedef TAO_ESF_Reconnected_Command<TAO_ESF_Delayed_Changes<PROXY,COLLECTION,ITERATOR,ACE_SYNCH_USE>,PROXY> TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::Reconnected_Command |
Definition at line 104 of file ESF_Delayed_Changes.h.
typedef TAO_ESF_Shutdown_Command<TAO_ESF_Delayed_Changes<PROXY,COLLECTION,ITERATOR,ACE_SYNCH_USE> > TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::Shutdown_Command |
Definition at line 106 of file ESF_Delayed_Changes.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::TAO_ESF_Delayed_Changes | ( | void | ) |
Definition at line 24 of file ESF_Delayed_Changes.cpp.
00025 : lock_ (this), 00026 busy_cond_ (busy_lock_), 00027 busy_count_ (0), 00028 write_delay_count_ (0), 00029 busy_hwm_ (TAO_ESF_DEFAULT_BUSY_HWM), 00030 max_write_delay_ (TAO_ESF_DEFAULT_MAX_WRITE_DELAY) 00031 { 00032 }
TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::TAO_ESF_Delayed_Changes | ( | const COLLECTION & | collection | ) |
Definition at line 36 of file ESF_Delayed_Changes.cpp.
00037 : collection_ (collection), 00038 lock_ (this), 00039 busy_cond_ (busy_lock_), 00040 busy_count_ (0), 00041 write_delay_count_ (0), 00042 busy_hwm_ (TAO_ESF_DEFAULT_BUSY_HWM), 00043 max_write_delay_ (TAO_ESF_DEFAULT_MAX_WRITE_DELAY) 00044 { 00045 }
int TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy | ( | void | ) |
Definition at line 64 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX_T, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_cond_, and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_count_.
00065 { 00066 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_, -1); 00067 00068 while (this->busy_count_ >= this->busy_hwm_ 00069 || this->write_delay_count_ >= this->max_write_delay_) 00070 this->busy_cond_.wait (); 00071 ++this->busy_count_; 00072 00073 return 0; 00074 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::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 110 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD_THROW_EX, ACE_NEW, ACE_SYNCH_MUTEX_T, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::command_queue_, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::connected_i(), ACE_Unbounded_Queue< T >::enqueue_tail(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::write_delay_count_.
00111 { 00112 ACE_GUARD_THROW_EX (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_, 00113 CORBA::INTERNAL ()); 00114 00115 proxy->_incr_refcnt (); 00116 if (this->busy_count_ == 0) 00117 { 00118 // We can add the object immediately 00119 this->connected_i (proxy); 00120 } 00121 else 00122 { 00123 ACE_Command_Base* command = 0; 00124 ACE_NEW (command, 00125 Connected_Command (this, 00126 proxy)); 00127 this->command_queue_.enqueue_tail (command); 00128 this->write_delay_count_++; 00129 } 00130 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL void TAO_ESF_Delayed_Changes< PROXY, C, I, >::connected_i | ( | PROXY * | proxy | ) |
Definition at line 9 of file ESF_Delayed_Changes.inl.
References TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::collection_.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::connected().
00010 { 00011 this->collection_.connected (proxy); 00012 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::disconnected | ( | PROXY * | proxy | ) | [virtual] |
Remove an element from the collection.
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 158 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD_THROW_EX, ACE_NEW, ACE_SYNCH_MUTEX_T, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::command_queue_, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::disconnected_i(), ACE_Unbounded_Queue< T >::enqueue_tail(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::write_delay_count_.
00159 { 00160 ACE_GUARD_THROW_EX (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_, 00161 CORBA::INTERNAL ()); 00162 00163 if (this->busy_count_ == 0) 00164 { 00165 // We can remove the object immediately 00166 this->disconnected_i (proxy); 00167 } 00168 else 00169 { 00170 ACE_Command_Base* command; 00171 ACE_NEW (command, 00172 Disconnected_Command (this, 00173 proxy)); 00174 this->command_queue_.enqueue_tail (command); 00175 this->write_delay_count_++; 00176 } 00177 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::disconnected_i | ( | PROXY * | proxy | ) |
Definition at line 23 of file ESF_Delayed_Changes.inl.
References TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::collection_.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::disconnected().
00024 { 00025 this->collection_.disconnected (proxy); 00026 }
int TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::execute_delayed_operations | ( | void | ) |
Definition at line 94 of file ESF_Delayed_Changes.cpp.
References TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::command_queue_, and ACE_Unbounded_Queue< T >::dequeue_head().
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::idle().
00095 { 00096 while (!this->command_queue_.is_empty ()) 00097 { 00098 ACE_Command_Base* command = 0; 00099 this->command_queue_.dequeue_head (command); 00100 00101 command->execute (); 00102 00103 delete command; 00104 } 00105 return 0; 00106 }
void TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::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 49 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::collection_, TAO_ESF_Worker< Object >::set_size(), and TAO_ESF_Worker< Object >::work().
00050 { 00051 ACE_GUARD (Busy_Lock, ace_mon, this->lock_); 00052 00053 worker->set_size(this->collection_.size()); 00054 ITERATOR end = this->collection_.end (); 00055 for (ITERATOR i = this->collection_.begin (); i != end; ++i) 00056 { 00057 worker->work (*i); 00058 00059 } 00060 }
int TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::idle | ( | void | ) |
Definition at line 78 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX_T, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_cond_, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_count_, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::execute_delayed_operations(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::write_delay_count_.
00079 { 00080 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_, -1); 00081 00082 --this->busy_count_; 00083 if (this->busy_count_ == 0) 00084 { 00085 this->write_delay_count_ = 0; 00086 this->execute_delayed_operations (); 00087 this->busy_cond_.broadcast (); 00088 } 00089 return 0; 00090 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::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 134 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD_THROW_EX, ACE_NEW, ACE_SYNCH_MUTEX_T, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::command_queue_, ACE_Unbounded_Queue< T >::enqueue_tail(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::reconnected_i(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::write_delay_count_.
00135 { 00136 ACE_GUARD_THROW_EX (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_, 00137 CORBA::INTERNAL ()); 00138 00139 proxy->_incr_refcnt (); 00140 if (this->busy_count_ == 0) 00141 { 00142 // We can reconnect the object immediately 00143 this->reconnected_i (proxy); 00144 } 00145 else 00146 { 00147 ACE_Command_Base* command; 00148 ACE_NEW (command, 00149 Reconnected_Command (this, 00150 proxy)); 00151 this->command_queue_.enqueue_tail (command); 00152 this->write_delay_count_++; 00153 } 00154 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::reconnected_i | ( | PROXY * | proxy | ) |
Definition at line 16 of file ESF_Delayed_Changes.inl.
References TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::collection_.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::reconnected().
00017 { 00018 this->collection_.reconnected (proxy); 00019 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::shutdown | ( | void | ) | [virtual] |
The EC is shutting down, must release all the elements.
Implements TAO_ESF_Proxy_Collection< PROXY >.
Definition at line 180 of file ESF_Delayed_Changes.cpp.
References ACE_GUARD_THROW_EX, ACE_NEW, ACE_SYNCH_MUTEX_T, TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::command_queue_, ACE_Unbounded_Queue< T >::enqueue_tail(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::shutdown_i(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::write_delay_count_.
00181 { 00182 ACE_GUARD_THROW_EX (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_, 00183 CORBA::INTERNAL ()); 00184 00185 if (this->busy_count_ == 0) 00186 { 00187 // We can shutdown the object immediately 00188 this->shutdown_i (); 00189 } 00190 else 00191 { 00192 ACE_Command_Base* command; 00193 ACE_NEW (command, 00194 Shutdown_Command (this)); 00195 this->command_queue_.enqueue_tail (command); 00196 this->write_delay_count_++; 00197 } 00198 }
void TAO_ESF_Delayed_Changes< PROXY, C, I, >::shutdown_i | ( | void | ) |
Definition at line 30 of file ESF_Delayed_Changes.inl.
References TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::collection_.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::shutdown().
00031 { 00032 this->collection_.shutdown (); 00033 }
ACE_SYNCH_CONDITION_T TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_cond_ [private] |
Definition at line 124 of file ESF_Delayed_Changes.h.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::idle().
CORBA::ULong TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_count_ [private] |
Definition at line 126 of file ESF_Delayed_Changes.h.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::idle().
CORBA::ULong TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_hwm_ [private] |
Control variables for the concurrency policies.
Definition at line 131 of file ESF_Delayed_Changes.h.
ACE_SYNCH_MUTEX_T TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_lock_ [private] |
Definition at line 122 of file ESF_Delayed_Changes.h.
COLLECTION TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::collection_ [private] |
Definition at line 116 of file ESF_Delayed_Changes.h.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::connected_i(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::disconnected_i(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::for_each(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::reconnected_i(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::shutdown_i().
ACE_Unbounded_Queue<ACE_Command_Base*> TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::command_queue_ [private] |
Definition at line 134 of file ESF_Delayed_Changes.h.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::connected(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::disconnected(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::execute_delayed_operations(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::reconnected(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::shutdown().
Busy_Lock TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::lock_ [private] |
Definition at line 120 of file ESF_Delayed_Changes.h.
CORBA::ULong TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::max_write_delay_ [private] |
Definition at line 132 of file ESF_Delayed_Changes.h.
CORBA::ULong TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::write_delay_count_ [private] |
Definition at line 128 of file ESF_Delayed_Changes.h.
Referenced by TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::connected(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::disconnected(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::idle(), TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::reconnected(), and TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::shutdown().