TAO_Wait_On_Read Class Reference

#include <Wait_On_Read.h>

Inheritance diagram for TAO_Wait_On_Read:

Inheritance graph
[legend]
Collaboration diagram for TAO_Wait_On_Read:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Wait_On_Read (TAO_Transport *transport)
 Constructor.
virtual ~TAO_Wait_On_Read (void)
 Destructor.
virtual int wait (ACE_Time_Value *max_wait_time, TAO_Synch_Reply_Dispatcher &rd)
virtual int register_handler (void)
virtual bool non_blocking (void) const
virtual bool can_process_upcalls (void) const

Detailed Description

Simply block on read() to wait for the reply.

Definition at line 32 of file Wait_On_Read.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Wait_On_Read::TAO_Wait_On_Read ( TAO_Transport transport  ) 

Constructor.

Definition at line 19 of file Wait_On_Read.cpp.

00020   : TAO_Wait_Strategy (transport)
00021 {
00022 }

TAO_Wait_On_Read::~TAO_Wait_On_Read ( void   )  [virtual]

Destructor.

Definition at line 25 of file Wait_On_Read.cpp.

00026 {
00027 }


Member Function Documentation

bool TAO_Wait_On_Read::can_process_upcalls ( void   )  const [virtual]

This flag is to check whether the thread can process upcalls while waiting for the reply. Some wait strategies, like Wait_On_LF_No_Upcall does not allow the client threads to process requests while waiting for the reply.

Implements TAO_Wait_Strategy.

Definition at line 131 of file Wait_On_Read.cpp.

00132 {
00133   return true;
00134 }

bool TAO_Wait_On_Read::non_blocking ( void   )  const [virtual]

Returns a value to indicate whether the transport needs to set the socket on which it is waiting to non-blocking mode or not.

Implements TAO_Wait_Strategy.

Definition at line 125 of file Wait_On_Read.cpp.

00126 {
00127   return false;
00128 }

int TAO_Wait_On_Read::register_handler ( void   )  [virtual]

Register the handler needs with the reactor provided that it makes sense for the strategy.

Implements TAO_Wait_Strategy.

Definition at line 119 of file Wait_On_Read.cpp.

00120 {
00121   return 0;
00122 }

int TAO_Wait_On_Read::wait ( ACE_Time_Value max_wait_time,
TAO_Synch_Reply_Dispatcher rd 
) [virtual]

Base class virtual method. Wait till the reply_received flag is true or the time expires.

Implements TAO_Wait_Strategy.

Definition at line 39 of file Wait_On_Read.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_TEXT, TAO_LF_Invocation_Event::error_detected(), TAO_Transport::event_handler_i(), TAO_Transport::handle_input(), TAO_Wait_Strategy::is_registered_, TAO_LF_Event::keep_waiting(), TAO_LF_Event::LFS_ACTIVE, LM_DEBUG, LM_ERROR, TAO_Transport::orb_core(), TAO_ORB_Core::reactor(), ACE_Event_Handler::READ_MASK, ACE_Reactor::register_handler(), TAO_LF_Event::state_changed(), TAO_LF_Invocation_Event::successful(), TAO_debug_level, and TAO_Wait_Strategy::transport_.

00041 {
00042   // Start the count down timer to account for the time spent in this
00043   // method.
00044   ACE_Countdown_Time countdown (max_wait_time);
00045 
00046   rd.state_changed (TAO_LF_Event::LFS_ACTIVE,
00047                     this->transport_->orb_core ()->leader_follower ());
00048 
00049   // Do the same sort of looping that is done in other wait
00050   // strategies.
00051   int retval = 0;
00052   TAO_Resume_Handle rh;
00053   while (1)
00054     {
00055       retval = this->transport_->handle_input (rh, max_wait_time);
00056 
00057       // If we got our reply, no need to run the loop any
00058       // further.
00059       if (!rd.keep_waiting ())
00060         break;
00061 
00062       // @@ We are not checking for timeouts here...
00063 
00064       // If we got an error just break
00065       if (retval == -1)
00066         break;
00067     }
00068 
00069   if (rd.error_detected () == -1 || retval == -1)
00070     {
00071       this->transport_->close_connection ();
00072     }
00073 
00074   if (rd.successful ())
00075      {
00076        TAO_ORB_Core * const oc =
00077          this->transport_->orb_core ();
00078 
00079        if (!oc->client_factory ()->use_cleanup_options ())
00080          return 0;
00081 
00082        if (TAO_debug_level > 0)
00083          ACE_DEBUG ((LM_DEBUG,
00084                      ACE_TEXT ("TAO (%P|%t) - TAO_Wait_On_Read[%d]::wait (), ")
00085                      ACE_TEXT ("registering handle for cleanup \n"),
00086                      this->transport_->id ()));
00087 
00088        ACE_Event_Handler * const eh =
00089          this->transport_->event_handler_i ();
00090 
00091        ACE_Reactor * const r =
00092          this->transport_->orb_core ()->reactor ();
00093 
00094        if (r->register_handler (eh,
00095                                 ACE_Event_Handler::READ_MASK) == -1)
00096          {
00097            if (TAO_debug_level > 0)
00098              ACE_ERROR ((LM_ERROR,
00099                          ACE_TEXT ("TAO (%P|%t) - TAO_Wait_On_Read[%d]::wait (), ")
00100                         ACE_TEXT ("registration with reactor returned an error \n"),
00101                          this->transport_->id ()));
00102         }
00103        else {
00104    // Only set this flag when registration succeeds
00105    this->is_registered_ = true;
00106        }
00107 
00108        return 0;
00109      }
00110 
00111   if (rd.error_detected ())
00112     return -1;
00113 
00114   return 1;
00115 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:51 2010 for TAO by  doxygen 1.4.7