Transport_Queueing_Strategies.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Transport_Queueing_Strategies.h
00006  *
00007  *  Transport_Queueing_Strategies.h,v 1.4 2005/11/24 11:05:46 ossama Exp
00008  *
00009  *  Queueing strategies for the ORB Messaging layer.
00010  *
00011  *  @author  Irfan Pyarali
00012  */
00013 //=============================================================================
00014 
00015 
00016 #ifndef TAO_TRANSPORT_QUEUEING_STRATEGIES_H
00017 #define TAO_TRANSPORT_QUEUEING_STRATEGIES_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "tao/TAO_Export.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "tao/orbconf.h"
00028 #include "tao/Basic_Types.h"
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 class ACE_Time_Value;
00032 ACE_END_VERSIONED_NAMESPACE_DECL
00033 
00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00035 
00036 class TAO_Stub;
00037 
00038 namespace TAO
00039 {
00040   struct BufferingConstraint;
00041 }
00042 
00043 namespace TimeBase
00044 {
00045   typedef CORBA::ULongLong TimeT;
00046 }
00047 
00048 namespace TAO
00049 {
00050   /// Define the interface for the Queueing Strategy
00051   /**
00052    * The low-level I/O components in the ORB use this strategy to
00053    * determine when messages must be queued, immediately sent or
00054    * flushed.
00055    *
00056    * The strategy isolates this low-level components from the higher
00057    * level strategies used by the application developer.
00058    */
00059   class Transport_Queueing_Strategy
00060   {
00061   public:
00062     /// Destructor
00063     virtual ~Transport_Queueing_Strategy (void);
00064 
00065     /// Return true if a message must be queued
00066     virtual bool must_queue (bool queue_empty) const = 0;
00067 
00068     /// Return true if it is time to start
00069     /**
00070      * @param stub The object used to make the request, this is used to
00071      *        obtain the policies currently in effect for the request
00072      * @param msg_count The number of messages currently queued
00073      * @param total_bytes Number of bytes currently queued
00074      * @param set_timer Returns true if a timer should be set to drain the
00075      *        queue
00076      * @param interval If set_timer returns 1, this parameter contains
00077      *        the timer interval
00078      * @param must_flush Is set to true if things must be flushed at this
00079      *        moment
00080      */
00081     virtual bool buffering_constraints_reached (
00082       TAO_Stub *stub,
00083       size_t msg_count,
00084       size_t total_bytes,
00085       bool &must_flush,
00086       const ACE_Time_Value &current_deadline,
00087       bool &set_timer,
00088       ACE_Time_Value &interval) const = 0;
00089   };
00090 
00091   class Default_Transport_Queueing_Strategy : public Transport_Queueing_Strategy
00092   {
00093   public:
00094     virtual bool must_queue (bool queue_empty) const;
00095 
00096     virtual bool buffering_constraints_reached (
00097       TAO_Stub *stub,
00098       size_t msg_count,
00099       size_t total_bytes,
00100       bool &must_flush,
00101       const ACE_Time_Value &current_deadline,
00102       bool &set_timer,
00103       ACE_Time_Value &interval) const;
00104   };
00105 
00106   /**
00107    * This strategy doesn't not queue by default, but when a message is queued
00108    * we always flush it to the transport. This is used for oneways with
00109    * SYNC_WITH_TRANSPORT, SYNC_WITH_SERVER and SYNC_WITH_TARGET
00110    */
00111   class Flush_Transport_Queueing_Strategy : public Transport_Queueing_Strategy
00112   {
00113   public:
00114     virtual bool must_queue (bool queue_empty) const;
00115 
00116     virtual bool buffering_constraints_reached (
00117       TAO_Stub *stub,
00118       size_t msg_count,
00119       size_t total_bytes,
00120       bool &must_flush,
00121       const ACE_Time_Value &current_deadline,
00122       bool &set_timer,
00123       ACE_Time_Value &interval) const;
00124   };
00125 
00126   #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00127 
00128   class Eager_Transport_Queueing_Strategy : public Transport_Queueing_Strategy
00129   {
00130   public:
00131     virtual bool must_queue (bool queue_empty) const;
00132 
00133     virtual bool buffering_constraints_reached (
00134       TAO_Stub *stub,
00135       size_t msg_count,
00136       size_t total_bytes,
00137       bool &must_flush,
00138       const ACE_Time_Value &current_deadline,
00139       bool &set_timer,
00140       ACE_Time_Value &new_deadline) const;
00141 
00142   private:
00143     /// Check if the buffering constraint includes any timeouts and
00144     /// compute the right timeout interval if needed.
00145     /**
00146      * @param buffering_constraint The constraints defined by the
00147      *        application
00148      * @param current_deadline The current deadline
00149      * @param set_timer Return true if the timer should be set
00150      * @param new_deadline Return the timer interval value
00151      *
00152      * @return Returns true if the deadline has already expired and
00153      *         flushing must commence immediately.  If the function
00154      *         returns false then flushing may need to be delayed, use @c
00155      *         set_timer and
00156      */
00157     bool timer_check (const TAO::BufferingConstraint &buffering_constraint,
00158                       const ACE_Time_Value &current_deadline,
00159                       bool &set_timer,
00160                       ACE_Time_Value &new_deadline) const;
00161 
00162     /// Convert from standard CORBA time units to seconds/microseconds.
00163     ACE_Time_Value time_conversion (const TimeBase::TimeT &time) const;
00164   };
00165 
00166   /// Delay the buffering decision until the transport blocks
00167   /**
00168    * If the queue is empty the transport will try to send immediately.
00169    */
00170   class Delayed_Transport_Queueing_Strategy
00171     : public Eager_Transport_Queueing_Strategy
00172   {
00173   public:
00174     virtual bool must_queue (bool queue_empty) const;
00175   };
00176 
00177   #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */
00178 
00179 }
00180 
00181 TAO_END_VERSIONED_NAMESPACE_DECL
00182 
00183 #include /**/ "ace/post.h"
00184 
00185 #endif /* TAO_TRANSPORT_QUEUEING_STRATEGY_H */

Generated on Thu Nov 9 11:54:27 2006 for TAO by doxygen 1.3.6