Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Leader_Follower_Flushing_Strategy.cpp
blobed8f46542272f610d634dd689276fe7bf1784f8c
1 #include "tao/Leader_Follower_Flushing_Strategy.h"
2 #include "tao/LF_Follower.h"
3 #include "tao/Leader_Follower.h"
4 #include "tao/Transport.h"
5 #include "tao/Queued_Message.h"
6 #include "tao/ORB_Core.h"
8 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
10 int
11 TAO_Leader_Follower_Flushing_Strategy::schedule_output (TAO_Transport *transport)
13 return transport->schedule_output_i ();
16 int
17 TAO_Leader_Follower_Flushing_Strategy::cancel_output (
18 TAO_Transport *transport)
20 return transport->cancel_output_i ();
23 int
24 TAO_Leader_Follower_Flushing_Strategy::flush_message (
25 TAO_Transport *transport,
26 TAO_Queued_Message *msg,
27 ACE_Time_Value *max_wait_time)
29 TAO_Leader_Follower &leader_follower =
30 transport->orb_core ()->leader_follower ();
31 return leader_follower.wait_for_event (msg, transport, max_wait_time);
34 int
35 TAO_Leader_Follower_Flushing_Strategy::flush_transport (
36 TAO_Transport *transport,
37 ACE_Time_Value *max_wait_time)
39 try
41 TAO_ORB_Core * const orb_core = transport->orb_core ();
43 while (!transport->queue_is_empty ())
45 // In case max_wait_time==0 we cannot simply run the orb because
46 // in multi-threaded applications it can easily happen that
47 // the other thread will run the orb and drain the queue in the
48 // transport we're coping with here and this thread will block.
49 // Instead we do run for a small amount of time and then recheck
50 // the queue.
51 if (max_wait_time == nullptr)
53 ACE_Errno_Guard eguard (errno);
55 // Poll the reactor's queue.
56 ACE_Time_Value tv = ACE_Time_Value::zero;
57 orb_core->orb ()->perform_work (&tv);
59 else
61 orb_core->orb ()->perform_work (max_wait_time);
64 if (max_wait_time != nullptr) {
65 if (*max_wait_time <= ACE_Time_Value::zero) {
66 errno = ETIME;
67 return -1;
72 catch (const ::CORBA::Exception&)
74 return -1;
77 return 0;
80 TAO_END_VERSIONED_NAMESPACE_DECL