Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / Wait_On_Reactor.cpp
blob2394a6506a98671be8da03b61d57ef5a8ccf9736
1 #include "tao/Wait_On_Reactor.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/Transport.h"
4 #include "tao/Synch_Reply_Dispatcher.h"
5 #include "tao/ORB_Time_Policy.h"
7 #include "ace/Reactor.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 TAO_Wait_On_Reactor::TAO_Wait_On_Reactor (TAO_Transport *transport)
12 : TAO_Wait_Strategy (transport)
16 int
17 TAO_Wait_On_Reactor::wait (ACE_Time_Value *max_wait_time,
18 TAO_Synch_Reply_Dispatcher &rd)
20 // Start the count down timer to account for the time spent in this
21 // method.
22 TAO::ORB_Countdown_Time countdown (max_wait_time);
24 // Reactor does not change inside the loop.
25 ACE_Reactor *const reactor =
26 this->transport_->orb_core ()->reactor ();
28 TAO_Leader_Follower &leader_follower =
29 this->transport_->orb_core ()->leader_follower ();
31 // Do the event loop, till we fully receive a reply.
32 int result = 0;
34 while (1)
36 // Run the event loop.
37 result = reactor->handle_events (max_wait_time);
39 // If we got our reply, no need to run the event loop any
40 // further.
41 if (!rd.keep_waiting (leader_follower))
43 break;
46 // Did we timeout? If so, stop running the loop.
47 if (result == 0
48 && max_wait_time != nullptr
49 && *max_wait_time == ACE_Time_Value::zero)
51 break;
54 // Other errors? If so, stop running the loop.
55 if (result == -1)
57 break;
60 // Otherwise, keep going...
63 if (result == -1 || rd.error_detected (leader_follower))
65 return -1;
68 // Return an error if there was a problem receiving the reply.
69 if (max_wait_time != nullptr)
71 if (rd.successful (leader_follower) && *max_wait_time == ACE_Time_Value::zero)
73 result = -1;
74 errno = ETIME;
77 else
79 result = 0;
81 if (rd.error_detected (leader_follower))
83 result = -1;
87 return result;
90 // Register the handler with the Reactor.
91 int
92 TAO_Wait_On_Reactor::register_handler ()
94 if (!this->is_registered_)
96 return this->transport_->register_handler ();
99 return 1;
102 bool
103 TAO_Wait_On_Reactor::non_blocking () const
105 return true;
108 bool
109 TAO_Wait_On_Reactor::can_process_upcalls () const
111 return true;
114 TAO_END_VERSIONED_NAMESPACE_DECL