#include <Messaging_Queueing_Strategies.h>


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 ¤t_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 ¤t_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. | |
Definition at line 47 of file Messaging_Queueing_Strategies.h.
| 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 & | interval | |||
| ) | const [virtual] |
Return true if it is time to start.
| 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 31 of file Messaging_Queueing_Strategies.cpp.
{
must_flush = false;
set_timer = false;
TAO::BufferingConstraint buffering_constraint;
try
{
CORBA::Policy_var bcp_policy =
stub->get_cached_policy (TAO_CACHED_POLICY_BUFFERING_CONSTRAINT);
TAO::BufferingConstraintPolicy_var bcpv =
TAO::BufferingConstraintPolicy::_narrow (bcp_policy.in ());
TAO_Buffering_Constraint_Policy* bcp =
dynamic_cast<TAO_Buffering_Constraint_Policy *> (bcpv.in ());
if (bcp == 0)
{
return true;
}
bcp->get_buffering_constraint (buffering_constraint);
}
catch (const ::CORBA::Exception&)
{
return true;
}
if (buffering_constraint.mode == TAO::BUFFER_FLUSH)
{
must_flush = true;
return true;
}
bool constraints_reached = false;
if (ACE_BIT_ENABLED (buffering_constraint.mode,
TAO::BUFFER_MESSAGE_COUNT)
&& msg_count >= buffering_constraint.message_count)
{
constraints_reached = true;
}
if (ACE_BIT_ENABLED (buffering_constraint.mode,
TAO::BUFFER_MESSAGE_BYTES)
&& total_bytes >= buffering_constraint.message_bytes)
{
constraints_reached = true;
}
if (this->timer_check (buffering_constraint,
current_deadline,
set_timer,
new_deadline))
{
constraints_reached = true;
}
return constraints_reached;
}
| 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 25 of file Messaging_Queueing_Strategies.cpp.
{
return true;
}
| 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 152 of file Messaging_Queueing_Strategies.cpp.
{
TimeBase::TimeT seconds = time / 10000000u;
TimeBase::TimeT microseconds = (time % 10000000u) / 10;
return ACE_Time_Value (ACE_U64_TO_U32 (seconds),
ACE_U64_TO_U32 (microseconds));
}
| 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] |
Check if the buffering constraint includes any timeouts and compute the right timeout interval if needed.
| 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 |
set_timer and Definition at line 101 of file Messaging_Queueing_Strategies.cpp.
{
set_timer = false;
if (!ACE_BIT_ENABLED (buffering_constraint.mode,
TAO::BUFFER_TIMEOUT))
{
return false;
}
// Compute the next deadline...
ACE_Time_Value const now = ACE_OS::gettimeofday ();
ACE_Time_Value timeout =
this->time_conversion (buffering_constraint.timeout);
new_deadline = now + timeout;
// Check if the new deadline is more stringent, or if the deadline
// has expired and thus must be reset anyway.
if (current_deadline > new_deadline
|| current_deadline < now)
{
set_timer = true;
}
// ... if there is no deadline we don't want to schedule output (the
// deadline will be set because set_timer is set to 1 in that case).
// If there is a deadline but but it has not been reached, we
// don't want to schedule any output either...
if (current_deadline == ACE_Time_Value::zero
|| current_deadline >= now)
{
return false;
}
if (TAO_debug_level > 6)
{
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - TAO_Eager_Buffering_Sync_Strategy::timer_check, "
"Now = %u, Current = %u, New = %u\n",
now.msec (), current_deadline.msec (),
new_deadline.msec ()));
}
return true;
}
1.7.0