TAO::Eager_Transport_Queueing_Strategy Class Reference

#include <Transport_Queueing_Strategies.h>

Inheritance diagram for TAO::Eager_Transport_Queueing_Strategy:

Inheritance graph
[legend]
Collaboration diagram for TAO::Eager_Transport_Queueing_Strategy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual bool must_queue (bool queue_empty) const
 Return true if a message must be queued.

virtual bool buffering_constraints_reached (TAO_Stub *stub, size_t msg_count, size_t total_bytes, bool &must_flush, const ACE_Time_Value &current_deadline, bool &set_timer, ACE_Time_Value &new_deadline) const
 Return true if it is time to start.


Private Member Functions

bool timer_check (const TAO::BufferingConstraint &buffering_constraint, const ACE_Time_Value &current_deadline, bool &set_timer, ACE_Time_Value &new_deadline) const
ACE_Time_Value time_conversion (const TimeBase::TimeT &time) const
 Convert from standard CORBA time units to seconds/microseconds.


Member Function Documentation

bool TAO::Eager_Transport_Queueing_Strategy::buffering_constraints_reached TAO_Stub stub,
size_t  msg_count,
size_t  total_bytes,
bool &  must_flush,
const ACE_Time_Value current_deadline,
bool &  set_timer,
ACE_Time_Value new_deadline
const [virtual]
 

Return true if it is time to start.

Parameters:
stub The object used to make the request, this is used to obtain the policies currently in effect for the request
msg_count The number of messages currently queued
total_bytes Number of bytes currently queued
set_timer Returns true if a timer should be set to drain the queue
interval If set_timer returns 1, this parameter contains the timer interval
must_flush Is set to true if things must be flushed at this moment

Implements TAO::Transport_Queueing_Strategy.

Definition at line 81 of file Transport_Queueing_Strategies.cpp.

References TAO::BufferingConstraintPolicy::_narrow(), ACE_BIT_ENABLED, ACE_CATCHANY, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, TAO::BufferingConstraintPolicy_var, TAO_Buffering_Constraint_Policy::get_buffering_constraint(), TAO_Stub::get_cached_policy(), TAO_Objref_Var_T< T >::in(), TAO::BufferingConstraint::message_bytes, TAO::BufferingConstraint::message_count, TAO::BufferingConstraint::mode, CORBA::Policy_var, TAO_CACHED_POLICY_BUFFERING_CONSTRAINT, and timer_check().

00089   {
00090     must_flush = false;
00091     set_timer = false;
00092 
00093     TAO_Buffering_Constraint_Policy *buffering_constraint_policy = 0;
00094 
00095     ACE_TRY_NEW_ENV
00096       {
00097         CORBA::Policy_var bcp_policy =
00098           stub->get_cached_policy (TAO_CACHED_POLICY_BUFFERING_CONSTRAINT
00099                                    ACE_ENV_ARG_PARAMETER);
00100         ACE_TRY_CHECK;
00101 
00102         TAO::BufferingConstraintPolicy_var bcp =
00103           TAO::BufferingConstraintPolicy::_narrow (bcp_policy.in ()
00104                                                    ACE_ENV_ARG_PARAMETER);
00105         ACE_TRY_CHECK;
00106 
00107         buffering_constraint_policy =
00108           dynamic_cast<TAO_Buffering_Constraint_Policy *> (bcp.in ());
00109 
00110         if (buffering_constraint_policy == 0)
00111           {
00112             return true;
00113           }
00114       }
00115     ACE_CATCHANY
00116       {
00117         return true;
00118       }
00119     ACE_ENDTRY;
00120 
00121     TAO::BufferingConstraint buffering_constraint;
00122     buffering_constraint_policy->get_buffering_constraint (buffering_constraint);
00123 
00124     if (buffering_constraint.mode == TAO::BUFFER_FLUSH)
00125       {
00126         must_flush = true;
00127         return true;
00128       }
00129 
00130     bool constraints_reached = false;
00131 
00132     if (ACE_BIT_ENABLED (buffering_constraint.mode,
00133                          TAO::BUFFER_MESSAGE_COUNT)
00134         && msg_count >= buffering_constraint.message_count)
00135       {
00136         constraints_reached = true;
00137       }
00138 
00139     if (ACE_BIT_ENABLED (buffering_constraint.mode,
00140                          TAO::BUFFER_MESSAGE_BYTES)
00141         && total_bytes >= buffering_constraint.message_bytes)
00142       {
00143         constraints_reached = true;
00144       }
00145 
00146     if (this->timer_check (buffering_constraint,
00147                            current_deadline,
00148                            set_timer,
00149                            new_deadline))
00150       {
00151         constraints_reached = true;
00152       }
00153 
00154     return constraints_reached;
00155   }

bool TAO::Eager_Transport_Queueing_Strategy::must_queue bool  queue_empty  )  const [virtual]
 

Return true if a message must be queued.

Implements TAO::Transport_Queueing_Strategy.

Reimplemented in TAO::Delayed_Transport_Queueing_Strategy.

Definition at line 75 of file Transport_Queueing_Strategies.cpp.

00076   {
00077     return true;
00078   }

ACE_Time_Value TAO::Eager_Transport_Queueing_Strategy::time_conversion const TimeBase::TimeT time  )  const [private]
 

Convert from standard CORBA time units to seconds/microseconds.

Definition at line 209 of file Transport_Queueing_Strategies.cpp.

References ACE_Time_Value, ACE_U64_TO_U32, and TimeBase::TimeT.

Referenced by timer_check().

00211   {
00212     TimeBase::TimeT seconds = time / 10000000u;
00213     TimeBase::TimeT microseconds = (time % 10000000u) / 10;
00214     return ACE_Time_Value (ACE_U64_TO_U32 (seconds),
00215                            ACE_U64_TO_U32 (microseconds));
00216   }

bool TAO::Eager_Transport_Queueing_Strategy::timer_check const TAO::BufferingConstraint buffering_constraint,
const ACE_Time_Value current_deadline,
bool &  set_timer,
ACE_Time_Value new_deadline
const [private]
 

Parameters:
buffering_constraint The constraints defined by the application
current_deadline The current deadline
set_timer Return true if the timer should be set
new_deadline Return the timer interval value
Returns:
Returns true if the deadline has already expired and flushing must commence immediately. If the function returns false then flushing may need to be delayed, use set_timer and

Definition at line 158 of file Transport_Queueing_Strategies.cpp.

References ACE_BIT_ENABLED, ACE_DEBUG, ACE_OS::gettimeofday(), LM_DEBUG, TAO::BufferingConstraint::mode, ACE_Time_Value::msec(), TAO_debug_level, time_conversion(), and TAO::BufferingConstraint::timeout.

Referenced by buffering_constraints_reached().

00163   {
00164     set_timer = false;
00165 
00166     if (!ACE_BIT_ENABLED (buffering_constraint.mode,
00167                           TAO::BUFFER_TIMEOUT))
00168       {
00169         return false;
00170       }
00171 
00172     // Compute the next deadline...
00173     ACE_Time_Value now = ACE_OS::gettimeofday ();
00174     ACE_Time_Value timeout =
00175       this->time_conversion (buffering_constraint.timeout);
00176     new_deadline = now + timeout;
00177 
00178     // Check if the new deadline is more stringent, or if the deadline
00179     // has expired and thus must be reset anyway.
00180     if (current_deadline > new_deadline
00181         || current_deadline < now)
00182       {
00183         set_timer = true;
00184       }
00185 
00186     // ... if there is no deadline we don't want to schedule output (the
00187     // deadline will be set because set_timer is set to 1 in that case).
00188     // If there is a deadline but but it has not been reached, we
00189     // don't want to schedule any output either...
00190     if (current_deadline == ACE_Time_Value::zero
00191         || current_deadline >= now)
00192       {
00193         return false;
00194       }
00195 
00196     if (TAO_debug_level > 6)
00197       {
00198         ACE_DEBUG ((LM_DEBUG,
00199                     "TAO (%P|%t) - TAO_Eager_Buffering_Sync_Strategy::timer_check, "
00200                     "Now = %u, Current = %u, New = %u\n",
00201                     now.msec (), current_deadline.msec (),
00202                     new_deadline.msec ()));
00203       }
00204 
00205     return true;
00206   }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:27:13 2006 for TAO by doxygen 1.3.6