CEC_Reactive_Pulling_Strategy.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CEC_Reactive_Pulling_Strategy.h
00006  *
00007  *  CEC_Reactive_Pulling_Strategy.h,v 1.21 2006/03/14 06:14:25 jtc Exp
00008  *
00009  *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_CEC_REACTIVE_PULLING_STRATEGY_H
00015 #define TAO_CEC_REACTIVE_PULLING_STRATEGY_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "orbsvcs/CosEvent/CEC_Pulling_Strategy.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "orbsvcs/ESF/ESF_Worker.h"
00026 
00027 #include "tao/ORB.h"
00028 #include "tao/PolicyC.h"
00029 
00030 #include "ace/Event_Handler.h"
00031 
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 class TAO_CEC_ProxyPullConsumer;
00036 class TAO_CEC_EventChannel;
00037 class TAO_CEC_ConsumerAdmin;
00038 class TAO_CEC_SupplierControl;
00039 class TAO_CEC_Reactive_Pulling_Strategy;
00040 
00041 /**
00042  * @class TAO_CEC_Pulling_Strategy_Adapter
00043  *
00044  * @brief Forwards timeout events to the Reactive Pulling Strategy
00045  *
00046  * The Reactive Pulling Strategy strategy uses the reactor to
00047  * periodically wakeup and try top pull events from each
00048  * PullSupplier connected to the EventChannel.
00049  */
00050 class TAO_Event_Serv_Export TAO_CEC_Pulling_Strategy_Adapter : public ACE_Event_Handler
00051 {
00052 public:
00053   /// Constructor
00054   TAO_CEC_Pulling_Strategy_Adapter (TAO_CEC_Reactive_Pulling_Strategy *adaptee);
00055 
00056   // = Documented in ACE_Event_Handler.
00057   virtual int handle_timeout (const ACE_Time_Value &tv,
00058                               const void *arg = 0);
00059 
00060 private:
00061   /// The adapted object
00062   TAO_CEC_Reactive_Pulling_Strategy *adaptee_;
00063 };
00064 
00065 // ****************************************************************
00066 
00067 /**
00068  * @class TAO_CEC_Reactive_Pulling_Strategy
00069  *
00070  * @brief Dispatch using the caller thread.
00071  *
00072  * The events are dispatched in FIFO ordering, using the invoking
00073  * thread to push the event to the consumer.
00074  */
00075 class TAO_Event_Serv_Export TAO_CEC_Reactive_Pulling_Strategy : public TAO_CEC_Pulling_Strategy
00076 {
00077 public:
00078   /// The scheduler is used to find the range of priorities and similar
00079   /// info.
00080   TAO_CEC_Reactive_Pulling_Strategy (const ACE_Time_Value &rate,
00081                                      const ACE_Time_Value &relative_timeout,
00082                                      TAO_CEC_EventChannel *event_channel,
00083                                      CORBA::ORB_ptr orb);
00084 
00085   /// Receive the timeout from the adapter
00086   void handle_timeout (const ACE_Time_Value &tv,
00087                        const void* arg);
00088 
00089   // = The CEC_Pulling_Strategy methods.
00090   virtual void activate (void);
00091   virtual void shutdown (void);
00092 
00093 private:
00094   /// The Adapter for the reactor events
00095   TAO_CEC_Pulling_Strategy_Adapter adapter_;
00096 
00097   /// The polling rate
00098   ACE_Time_Value rate_;
00099 
00100   /// The relative timeout
00101   ACE_Time_Value relative_timeout_;
00102 
00103   /// The event channel
00104   TAO_CEC_EventChannel *event_channel_;
00105 
00106   /// The ORB
00107   CORBA::ORB_var orb_;
00108 
00109   /// To control the timeout policy in the thread
00110   CORBA::PolicyCurrent_var policy_current_;
00111 
00112   /// Precomputed policy list to the set timeout.
00113   CORBA::PolicyList policy_list_;
00114 
00115   /// The ORB reactor
00116   ACE_Reactor *reactor_;
00117 
00118 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00119   /// The timer id
00120   long timer_id_;
00121 #endif /* TAO_HAS_CORBA_MESSAGING */
00122 };
00123 
00124 // ****************************************************************
00125 
00126 class TAO_CEC_Pull_Event : public TAO_ESF_Worker<TAO_CEC_ProxyPullConsumer>
00127 {
00128 public:
00129   TAO_CEC_Pull_Event (TAO_CEC_ConsumerAdmin *consumer_admin,
00130                       TAO_CEC_SupplierControl *control);
00131 
00132   virtual void work (TAO_CEC_ProxyPullConsumer *consumer
00133                      ACE_ENV_ARG_DECL);
00134 
00135 private:
00136   /// Used to propagate the events.
00137   TAO_CEC_ConsumerAdmin *consumer_admin_;
00138 
00139   /// To report failed or dead suppliers
00140   TAO_CEC_SupplierControl *supplier_control_;
00141 };
00142 
00143 TAO_END_VERSIONED_NAMESPACE_DECL
00144 
00145 #if defined (__ACE_INLINE__)
00146 #include "orbsvcs/CosEvent/CEC_Reactive_Pulling_Strategy.i"
00147 #endif /* __ACE_INLINE__ */
00148 
00149 #include /**/ "ace/post.h"
00150 
00151 #endif /* TAO_CEC_REACTIVE_PULLING_STRATEGY_H */

Generated on Thu Nov 9 13:18:17 2006 for TAO_CosEvent by doxygen 1.3.6