TAO_EC_Per_Supplier_Filter Class Reference

Filter the events on each supplier. More...

#include <EC_Per_Supplier_Filter.h>

Inheritance diagram for TAO_EC_Per_Supplier_Filter:

Inheritance graph
[legend]
Collaboration diagram for TAO_EC_Per_Supplier_Filter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_EC_Per_Supplier_Filter (TAO_EC_Event_Channel_Base *ec)
 Constructor.

virtual ~TAO_EC_Per_Supplier_Filter (void)
 Destructor.

virtual void bind (TAO_EC_ProxyPushConsumer *consumer)
virtual void unbind (TAO_EC_ProxyPushConsumer *consumer)
virtual void connected (TAO_EC_ProxyPushSupplier *supplier)
virtual void reconnected (TAO_EC_ProxyPushSupplier *supplier)
virtual void disconnected (TAO_EC_ProxyPushSupplier *supplier)
virtual void shutdown (void)
 The event channel is shutting down.

virtual void push (const RtecEventComm::EventSet &event, TAO_EC_ProxyPushConsumer *consumer)
virtual void push_scheduled_event (RtecEventComm::EventSet &event, const TAO_EC_QOS_Info &event_info)
virtual CORBA::ULong _decr_refcnt (void)
virtual CORBA::ULong _incr_refcnt (void)

Private Attributes

TAO_EC_Event_Channel_Baseevent_channel_
 The event channel, used to locate the set of consumers.

TAO_EC_ProxyPushConsumerconsumer_
 The proxy for the supplier we are bound to.

TAO_ESF_Proxy_Collection<
TAO_EC_ProxyPushSupplier > * 
collection_
CORBA::ULong refcnt_
 Reference counting.

TAO_SYNCH_MUTEX lock_
 Locking.


Detailed Description

Filter the events on each supplier.

This is a filtering strategy for the suppliers. In this particular case we keep a collection of the consumers that could potentially be interested in any event generated by a particular supplier. This minimizes the amount of consumers touched by the EC when dispatching an event.

Definition at line 44 of file EC_Per_Supplier_Filter.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_EC_Per_Supplier_Filter::TAO_EC_Per_Supplier_Filter TAO_EC_Event_Channel_Base ec  ) 
 

Constructor.

Definition at line 23 of file EC_Per_Supplier_Filter.cpp.

References TAO_EC_Event_Channel_Base::create_proxy_collection().

00024   :  event_channel_ (ec),
00025      consumer_ (0),
00026      refcnt_ (1)
00027 {
00028   this->event_channel_->create_proxy_collection (this->collection_);
00029 }

TAO_EC_Per_Supplier_Filter::~TAO_EC_Per_Supplier_Filter void   )  [virtual]
 

Destructor.

Definition at line 31 of file EC_Per_Supplier_Filter.cpp.

References TAO_EC_Event_Channel_Base::destroy_proxy_collection().

00032 {
00033   this->event_channel_->destroy_proxy_collection (this->collection_);
00034   this->collection_ = 0;
00035 }


Member Function Documentation

CORBA::ULong TAO_EC_Per_Supplier_Filter::_decr_refcnt void   )  [virtual]
 

Implements TAO_EC_Supplier_Filter.

Definition at line 174 of file EC_Per_Supplier_Filter.cpp.

References ACE_GUARD_RETURN, TAO_EC_Supplier_Filter_Builder::destroy(), refcnt_, TAO_EC_Event_Channel_Base::supplier_filter_builder(), and TAO_SYNCH_MUTEX.

00175 {
00176   {
00177     ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00178 
00179     this->refcnt_--;
00180     if (this->refcnt_ != 0)
00181       return this->refcnt_;
00182   }
00183   this->event_channel_->supplier_filter_builder ()->destroy (this);
00184   return 0;
00185 }

CORBA::ULong TAO_EC_Per_Supplier_Filter::_incr_refcnt void   )  [virtual]
 

Increment and decrement the reference count, locking must be provided by the user.

Implements TAO_EC_Supplier_Filter.

Definition at line 165 of file EC_Per_Supplier_Filter.cpp.

References ACE_GUARD_RETURN, refcnt_, and TAO_SYNCH_MUTEX.

00166 {
00167   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00168 
00169   this->refcnt_++;
00170   return this->refcnt_;
00171 }

void TAO_EC_Per_Supplier_Filter::bind TAO_EC_ProxyPushConsumer consumer  )  [virtual]
 

Whenever a ProxyPushConsumer is initialized it calls this method to inform the Supplier_Filter of its identity. Strategies that do not keep ProxyPushConsumer specific information, or that are shared between multiple ProxyPushConsumers can ignore this message.

Implements TAO_EC_Supplier_Filter.

Definition at line 38 of file EC_Per_Supplier_Filter.cpp.

References ACE_GUARD, and TAO_SYNCH_MUTEX.

00039 {
00040   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00041 
00042   if (this->consumer_ != 0)
00043     return;
00044 
00045   this->consumer_ = consumer;
00046 }

void TAO_EC_Per_Supplier_Filter::connected TAO_EC_ProxyPushSupplier supplier  )  [virtual]
 

Concrete implementations can use this methods to keep track of the consumers interested in this events.

Implements TAO_EC_Supplier_Filter.

Definition at line 69 of file EC_Per_Supplier_Filter.cpp.

References ACE_DEBUG, ACE_GUARD, TAO_EC_ProxyPushSupplier::can_match(), TAO_ESF_Proxy_Collection< TAO_EC_ProxyPushSupplier >::connected(), RtecEventComm::Event::header, LM_DEBUG, RtecEventChannelAdmin::SupplierQOS::publications, TAO_EC_ProxyPushConsumer::publications_i(), and TAO_SYNCH_MUTEX.

00070 {
00071   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00072 
00073   if (this->consumer_ == 0)
00074     return;
00075 
00076   const RtecEventChannelAdmin::SupplierQOS& pub =
00077     this->consumer_->publications_i ();
00078 
00079   for (CORBA::ULong j = 0; j < pub.publications.length (); ++j)
00080     {
00081       const RtecEventComm::Event& event =
00082         pub.publications[j].event;
00083 
00084 #if TAO_EC_ENABLE_DEBUG_MESSAGES
00085       ACE_DEBUG ((LM_DEBUG, "Connecting consumer <%x> to <%x>, "
00086                   "trying event <%d:%d>  ",
00087                   supplier, this,
00088                   event.header.source, event.header.type));
00089 #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */
00090       if (supplier->can_match (event.header))
00091         {
00092 #if TAO_EC_ENABLE_DEBUG_MESSAGES
00093           ACE_DEBUG ((LM_DEBUG, "  matched\n"));
00094 #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */
00095           this->collection_->connected (supplier);
00096           return;
00097         }
00098 #if TAO_EC_ENABLE_DEBUG_MESSAGES
00099       ACE_DEBUG ((LM_DEBUG, "  not matched\n"));
00100 #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */
00101     }
00102 }

void TAO_EC_Per_Supplier_Filter::disconnected TAO_EC_ProxyPushSupplier supplier  )  [virtual]
 

Implements TAO_EC_Supplier_Filter.

Definition at line 134 of file EC_Per_Supplier_Filter.cpp.

References TAO_ESF_Proxy_Collection< TAO_EC_ProxyPushSupplier >::disconnected().

00135 {
00136   this->collection_->disconnected (supplier);
00137 }

void TAO_EC_Per_Supplier_Filter::push const RtecEventComm::EventSet event,
TAO_EC_ProxyPushConsumer consumer
[virtual]
 

The ProxyPushConsumer delegates on this class to actually send the event.

Implements TAO_EC_Supplier_Filter.

Definition at line 146 of file EC_Per_Supplier_Filter.cpp.

References RtecEventComm::EventSet, TAO_EC_Scheduling_Strategy::schedule_event(), and TAO_EC_Event_Channel_Base::scheduling_strategy().

00148 {
00149   TAO_EC_Scheduling_Strategy* scheduling_strategy =
00150     this->event_channel_->scheduling_strategy ();
00151   scheduling_strategy->schedule_event (event,
00152                                        consumer,
00153                                        this);
00154 }

void TAO_EC_Per_Supplier_Filter::push_scheduled_event RtecEventComm::EventSet event,
const TAO_EC_QOS_Info event_info
[virtual]
 

Events are first scheduled by the TAO_EC_Scheduling_Strategy, and then pushed through this class again.

Implements TAO_EC_Supplier_Filter.

Definition at line 157 of file EC_Per_Supplier_Filter.cpp.

References RtecEventComm::EventSet, and TAO_ESF_Proxy_Collection< TAO_EC_ProxyPushSupplier >::for_each().

00159 {
00160   TAO_EC_Filter_Worker worker (event, event_info);
00161   this->collection_->for_each (&worker);
00162 }

void TAO_EC_Per_Supplier_Filter::reconnected TAO_EC_ProxyPushSupplier supplier  )  [virtual]
 

Implements TAO_EC_Supplier_Filter.

Definition at line 105 of file EC_Per_Supplier_Filter.cpp.

References ACE_GUARD, TAO_EC_ProxyPushSupplier::can_match(), TAO_ESF_Proxy_Collection< TAO_EC_ProxyPushSupplier >::connected(), TAO_ESF_Proxy_Collection< TAO_EC_ProxyPushSupplier >::disconnected(), RtecEventComm::Event::header, RtecEventChannelAdmin::SupplierQOS::publications, TAO_EC_ProxyPushConsumer::publications_i(), and TAO_SYNCH_MUTEX.

00106 {
00107   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00108 
00109   if (this->consumer_ == 0)
00110     return;
00111 
00112   const RtecEventChannelAdmin::SupplierQOS& pub =
00113     this->consumer_->publications_i ();
00114 
00115   for (CORBA::ULong j = 0; j < pub.publications.length (); ++j)
00116     {
00117       const RtecEventComm::Event& event =
00118         pub.publications[j].event;
00119 
00120       //      ACE_DEBUG ((LM_DEBUG, "Trying %d:%d in %x\n",
00121       //                  event.header.source, event.header.type,
00122       //                  this));
00123       if (supplier->can_match (event.header))
00124         {
00125           //          ACE_DEBUG ((LM_DEBUG, "  matched %x\n", supplier));
00126           this->collection_->connected (supplier);
00127           return;
00128         }
00129     }
00130   this->collection_->disconnected (supplier);
00131 }

void TAO_EC_Per_Supplier_Filter::shutdown void   )  [virtual]
 

The event channel is shutting down.

Implements TAO_EC_Supplier_Filter.

Definition at line 140 of file EC_Per_Supplier_Filter.cpp.

References TAO_ESF_Proxy_Collection< TAO_EC_ProxyPushSupplier >::shutdown().

Referenced by unbind().

00141 {
00142   this->collection_->shutdown ();
00143 }

void TAO_EC_Per_Supplier_Filter::unbind TAO_EC_ProxyPushConsumer consumer  )  [virtual]
 

Wheneve a ProxyPushConsumer is about to be destroyed it calls this method to inform the Supplier_Filter that it should release any resources related to it. Supplier_Filter strategies that are bound to a particular ProxyConsumer can use this opportunity to destroy themselves; filter strategies that do not keep ProxyPushConsumer specific information can simply ignore the message.

Implements TAO_EC_Supplier_Filter.

Definition at line 49 of file EC_Per_Supplier_Filter.cpp.

References ACE_GUARD, shutdown(), and TAO_SYNCH_MUTEX.

00050 {
00051   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00052 
00053   if (this->consumer_ == 0 || this->consumer_ != consumer)
00054     return;
00055 
00056   this->consumer_ = 0;
00057 
00058   try
00059     {
00060       this->shutdown ();
00061     }
00062   catch (const CORBA::Exception&)
00063     {
00064       // @@ Ignore exceptions
00065     }
00066 }


Member Data Documentation

TAO_ESF_Proxy_Collection<TAO_EC_ProxyPushSupplier>* TAO_EC_Per_Supplier_Filter::collection_ [private]
 

Keep the collection of proxies for the consumers that may be interested in our events.

Definition at line 76 of file EC_Per_Supplier_Filter.h.

TAO_EC_ProxyPushConsumer* TAO_EC_Per_Supplier_Filter::consumer_ [private]
 

The proxy for the supplier we are bound to.

Definition at line 72 of file EC_Per_Supplier_Filter.h.

TAO_EC_Event_Channel_Base* TAO_EC_Per_Supplier_Filter::event_channel_ [private]
 

The event channel, used to locate the set of consumers.

Definition at line 69 of file EC_Per_Supplier_Filter.h.

TAO_SYNCH_MUTEX TAO_EC_Per_Supplier_Filter::lock_ [private]
 

Locking.

Definition at line 82 of file EC_Per_Supplier_Filter.h.

CORBA::ULong TAO_EC_Per_Supplier_Filter::refcnt_ [private]
 

Reference counting.

Definition at line 79 of file EC_Per_Supplier_Filter.h.

Referenced by _decr_refcnt(), and _incr_refcnt().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:42:37 2008 for TAO_RTEvent by doxygen 1.3.6