Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Eager_Buffering_Sync_Strategy Class Reference

#include <Sync_Strategies.h>

Inheritance diagram for TAO_Eager_Buffering_Sync_Strategy:

Inheritance graph
[legend]
Collaboration diagram for TAO_Eager_Buffering_Sync_Strategy:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual int must_queue (int queue_empty)
 Return 1 if a message must be queued. More...

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


Private Methods

int timer_check (const TAO::BufferingConstraint &buffering_constraint, const ACE_Time_Value &current_deadline, int &set_timer, ACE_Time_Value &new_deadline)
 Check if the buffering constraint includes any timeouts and compute the right timeout interval if needed. More...

ACE_Time_Value time_conversion (const TimeBase::TimeT &time)
 Convert from standard CORBA time units to seconds/microseconds. More...


Member Function Documentation

int TAO_Eager_Buffering_Sync_Strategy::buffering_constraints_reached TAO_Stub   stub,
size_t    msg_count,
size_t    total_bytes,
int &    must_flush,
const ACE_Time_Value   current_deadline,
int &    set_timer,
ACE_Time_Value   new_deadline
[virtual]
 

Return 1 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 1 if a timer should be set to drain the queue
interval  If set_timer returns 1, this parameter contains the timer interval

Implements TAO_Sync_Strategy.

Definition at line 58 of file Sync_Strategies.cpp.

References TAO::BufferingConstraintPolicy::_narrow, ACE_BIT_ENABLED, TAO_Stub::buffering_constraint, TAO_Buffering_Constraint_Policy::get_buffering_constraint, TAO::BufferingConstraintPolicy_var::in, CORBA::Policy_var::in, TAO::BufferingConstraint::message_bytes, TAO::BufferingConstraint::message_count, TAO::BufferingConstraint::mode, and timer_check.

00065 {
00066   must_flush = 0;
00067   set_timer = 0;
00068 
00069   CORBA::Policy_var bcp_policy = stub->buffering_constraint ();
00070   TAO::BufferingConstraintPolicy_var bcp = 
00071     TAO::BufferingConstraintPolicy::_narrow (bcp_policy.in());
00072 
00073   TAO_Buffering_Constraint_Policy *buffering_constraint_policy =
00074     ACE_dynamic_cast (TAO_Buffering_Constraint_Policy *, bcp.in ());
00075 
00076   if (buffering_constraint_policy == 0)
00077     return 1;
00078 
00079   TAO::BufferingConstraint buffering_constraint;
00080   buffering_constraint_policy->get_buffering_constraint (buffering_constraint);
00081 
00082   if (buffering_constraint.mode == TAO::BUFFER_FLUSH)
00083     {
00084       must_flush = 1;
00085       return 1;
00086     }
00087 
00088   int constraints_reached = 0;
00089   if (ACE_BIT_ENABLED (buffering_constraint.mode,
00090                        TAO::BUFFER_MESSAGE_COUNT)
00091       && msg_count >= buffering_constraint.message_count)
00092     constraints_reached = 1;
00093 
00094   if (ACE_BIT_ENABLED (buffering_constraint.mode,
00095                        TAO::BUFFER_MESSAGE_BYTES)
00096       && total_bytes >= buffering_constraint.message_bytes)
00097     constraints_reached = 1;
00098 
00099   if (this->timer_check (buffering_constraint,
00100                          current_deadline,
00101                          set_timer,
00102                          new_deadline) != 0)
00103     constraints_reached = 1;
00104 
00105   return constraints_reached;
00106 }

int TAO_Eager_Buffering_Sync_Strategy::must_queue int    queue_empty [virtual]
 

Return 1 if a message must be queued.

Implements TAO_Sync_Strategy.

Reimplemented in TAO_Delayed_Buffering_Sync_Strategy.

Definition at line 51 of file Sync_Strategies.cpp.

00052 {
00053   return 1;
00054 }

ACE_Time_Value TAO_Eager_Buffering_Sync_Strategy::time_conversion const TimeBase::TimeT   time [private]
 

Convert from standard CORBA time units to seconds/microseconds.

Definition at line 160 of file Sync_Strategies.cpp.

References ACE_U64_TO_U32.

Referenced by timer_check.

00161 {
00162   TimeBase::TimeT seconds = time / 10000000u;
00163   TimeBase::TimeT microseconds = (time % 10000000u) / 10;
00164   return ACE_Time_Value (ACE_U64_TO_U32 (seconds),
00165                          ACE_U64_TO_U32 (microseconds));
00166 }

int TAO_Eager_Buffering_Sync_Strategy::timer_check const TAO::BufferingConstraint   buffering_constraint,
const ACE_Time_Value   current_deadline,
int &    set_timer,
ACE_Time_Value   new_deadline
[private]
 

Check if the buffering constraint includes any timeouts and compute the right timeout interval if needed.

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

Definition at line 110 of file Sync_Strategies.cpp.

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

Referenced by buffering_constraints_reached.

00114 {
00115   set_timer = 0;
00116   if (!ACE_BIT_ENABLED (buffering_constraint.mode,
00117                         TAO::BUFFER_TIMEOUT))
00118     {
00119       return 0;
00120     }
00121 
00122   // Compute the next deadline...
00123   ACE_Time_Value now = ACE_OS::gettimeofday ();
00124   ACE_Time_Value timeout =
00125     this->time_conversion (buffering_constraint.timeout);
00126   new_deadline = now + timeout;
00127 
00128   // Check if the new deadline is more stringent, or if the deadline
00129   // has expired and thus must be reset anyway.
00130   if (current_deadline > new_deadline
00131       || current_deadline < now)
00132     {
00133       set_timer = 1;
00134     }
00135 
00136   // ... if there is no deadline we don't want to schedule output (the
00137   // deadline will be set because set_timer is set to 1 in that case).
00138   // If there is a deadline but but it has not been reached, we
00139   // don't want to schedule any output either...
00140   if (current_deadline == ACE_Time_Value::zero
00141       || current_deadline >= now)
00142     {
00143       return 0;
00144     }
00145 
00146   if (TAO_debug_level > 6)
00147     {
00148       ACE_DEBUG ((LM_DEBUG,
00149                   "TAO (%P|%t) - TAO_Eager_Buffering_Sync_Strategy::timer_check, "
00150                   "Now = %u, Current = %u, New = %u\n",
00151                   now.msec (), current_deadline.msec (),
00152                   new_deadline.msec ()));
00153     }
00154 
00155   return 1;
00156 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:14:38 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002