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

TAO_ESF_Delayed_Operations. More...

#include <ESF_Delayed_Changes.h>

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

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

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_ESF_Connected_Command<
TAO_ESF_Delayed_Changes<
PROXY, COLLECTION, ITERATOR,
ACE_SYNCH_USE >, PROXY > 
Connected_Command
typedef TAO_ESF_Reconnected_Command<
TAO_ESF_Delayed_Changes<
PROXY, COLLECTION, ITERATOR,
ACE_SYNCH_USE >, PROXY > 
Reconnected_Command
typedef TAO_ESF_Disconnected_Command<
TAO_ESF_Delayed_Changes<
PROXY, COLLECTION, ITERATOR,
ACE_SYNCH_USE >, PROXY > 
Disconnected_Command
typedef TAO_ESF_Shutdown_Command<
TAO_ESF_Delayed_Changes<
PROXY, COLLECTION, ITERATOR,
ACE_SYNCH_USE > > 
Shutdown_Command

Public Member Functions

 TAO_ESF_Delayed_Changes (void)
 TAO_ESF_Delayed_Changes (const COLLECTION &collection)
int busy (void)
int idle (void)
int execute_delayed_operations (void)
void connected_i (PROXY *proxy)
void reconnected_i (PROXY *proxy)
void disconnected_i (PROXY *proxy)
void shutdown_i (void)
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_Busy_Lock_Adapter<
TAO_ESF_Delayed_Changes<
PROXY, COLLECTION, ITERATOR,
ACE_SYNCH_USE > > 
Busy_Lock

Private Attributes

COLLECTION collection_
Busy_Lock lock_
ACE_SYNCH_MUTEX_T busy_lock_
ACE_SYNCH_CONDITION_T busy_cond_
CORBA::ULong busy_count_
CORBA::ULong write_delay_count_
CORBA::ULong busy_hwm_
 Control variables for the concurrency policies.
CORBA::ULong max_write_delay_
ACE_Unbounded_Queue< ACE_Command_Base * > command_queue_

Detailed Description

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

TAO_ESF_Delayed_Operations.

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.


Member Typedef Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.


Constructor & Destructor Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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 }


Member Function Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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 }

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }

template<class PROXY, class C, class I, ACE_SYNCH_DECL >
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 }


Member Data Documentation

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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().

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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().

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
ACE_SYNCH_MUTEX_T TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::busy_lock_ [private]

Definition at line 122 of file ESF_Delayed_Changes.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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().

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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().

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
Busy_Lock TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::lock_ [private]

Definition at line 120 of file ESF_Delayed_Changes.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
CORBA::ULong TAO_ESF_Delayed_Changes< PROXY, COLLECTION, ITERATOR, >::max_write_delay_ [private]

Definition at line 132 of file ESF_Delayed_Changes.h.

template<class PROXY, class COLLECTION, class ITERATOR, ACE_SYNCH_DECL >
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().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:43:51 2010 for TAO_ESF by  doxygen 1.4.7