Go to the documentation of this file.00001
00002
00003 #include "tao/Block_Flushing_Strategy.h"
00004 #include "tao/Transport.h"
00005 #include "tao/Queued_Message.h"
00006 #include "tao/Connection_Handler.h"
00007 #include "ace/Countdown_Time.h"
00008
00009 ACE_RCSID(tao, Block_Flushing_Strategy, "$Id: Block_Flushing_Strategy.cpp 85817 2009-06-26 20:44:58Z mitza $")
00010
00011 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00012
00013 int
00014 TAO_Block_Flushing_Strategy::schedule_output (TAO_Transport *)
00015 {
00016 return MUST_FLUSH;
00017 }
00018
00019 int
00020 TAO_Block_Flushing_Strategy::cancel_output (TAO_Transport *)
00021 {
00022 return 0;
00023 }
00024
00025 int
00026 TAO_Block_Flushing_Strategy::call_handle_output (TAO_Transport *transport,
00027 const TAO::Transport::Drain_Constraints &dc)
00028 {
00029 switch (transport->handle_output (dc).dre_)
00030 {
00031 case TAO_Transport::DR_ERROR: return -1;
00032 case TAO_Transport::DR_QUEUE_EMPTY:
00033 case TAO_Transport::DR_OK: return 0;
00034 case TAO_Transport::DR_WOULDBLOCK:
00035 {
00036 ACE_Countdown_Time counter (dc.timeout ());
00037 TAO_Connection_Handler &ch = *transport->connection_handler ();
00038 if (ch.handle_write_ready (dc.timeout ()) == -1)
00039 {
00040 return -1;
00041 }
00042 return 0;
00043 }
00044 }
00045 return 0;
00046 }
00047
00048 int
00049 TAO_Block_Flushing_Strategy::flush_message (TAO_Transport *transport,
00050 TAO_Queued_Message *msg,
00051 ACE_Time_Value *max_wait_time)
00052 {
00053 TAO::Transport::Drain_Constraints dc (max_wait_time, true);
00054 while (!msg->all_data_sent ())
00055 {
00056 if (this->call_handle_output (transport, dc) == -1)
00057 return -1;
00058 }
00059 return 0;
00060 }
00061
00062 int
00063 TAO_Block_Flushing_Strategy::flush_transport (TAO_Transport *transport,
00064 ACE_Time_Value *max_wait_time)
00065 {
00066 TAO::Transport::Drain_Constraints dc (max_wait_time, true);
00067 while (!transport->queue_is_empty ())
00068 {
00069 if (this->call_handle_output (transport, dc) == -1)
00070 return -1;
00071 }
00072 return 0;
00073 }
00074
00075 TAO_END_VERSIONED_NAMESPACE_DECL