TAO_Resume_Handle Class Reference

A utility class that helps in resuming handlers if TAO uses a TP Reactor from ACE. More...

#include <Resume_Handle.h>

Collaboration diagram for TAO_Resume_Handle:

Collaboration graph
[legend]
List of all members.

Public Types

enum  TAO_Handle_Resume_Flag { TAO_HANDLE_RESUMABLE = 0, TAO_HANDLE_ALREADY_RESUMED, TAO_HANDLE_LEAVE_SUSPENDED }

Public Member Functions

 TAO_Resume_Handle (TAO_ORB_Core *orb_core=0, ACE_HANDLE h=ACE_INVALID_HANDLE)
 Ctor.

 ~TAO_Resume_Handle (void)
 Dtor.

void set_flag (TAO_Handle_Resume_Flag fl)
 Allow the users of this class to change the underlying flag.

TAO_Resume_Handleoperator= (const TAO_Resume_Handle &rhs)
 Assignment operator.

void resume_handle (void)
void handle_input_return_value_hook (int &return_value)

Private Attributes

TAO_ORB_Coreorb_core_
 Our ORB Core.

ACE_HANDLE handle_
 The actual handle that needs resumption..

TAO_Handle_Resume_Flag flag_

Detailed Description

A utility class that helps in resuming handlers if TAO uses a TP Reactor from ACE.

Please read the documentation in the bugzilla #575 in the bugzilla database what we mean by handler resumption.

When TAO uses a TP reactor, it takes care of resuming the handler once it makes sure that it has read the whole message out of the socket. During the process of reading the transport object would have to deal with errors in 'read' from the socket, or errors in the messages that has been received. Instead of calling resume_handler () on the reactor at every point in the code, we use this utility class to take care of the resumption.

Definition at line 48 of file Resume_Handle.h.


Member Enumeration Documentation

enum TAO_Resume_Handle::TAO_Handle_Resume_Flag
 

Enumeration values:
TAO_HANDLE_RESUMABLE 
TAO_HANDLE_ALREADY_RESUMED 
TAO_HANDLE_LEAVE_SUSPENDED 

Definition at line 59 of file Resume_Handle.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_Resume_Handle::TAO_Resume_Handle TAO_ORB_Core orb_core = 0,
ACE_HANDLE  h = ACE_INVALID_HANDLE
 

Ctor.

Definition at line 8 of file Resume_Handle.inl.

00010   : orb_core_ (orb_core),
00011     handle_ (h),
00012     flag_ (TAO_HANDLE_RESUMABLE)
00013 {
00014 }

ACE_INLINE TAO_Resume_Handle::~TAO_Resume_Handle void   ) 
 

Dtor.

Definition at line 17 of file Resume_Handle.inl.

References flag_, resume_handle(), and TAO_HANDLE_RESUMABLE.

00018 {
00019   if (this->flag_ == TAO_HANDLE_RESUMABLE)
00020     this->resume_handle ();
00021 }


Member Function Documentation

void TAO_Resume_Handle::handle_input_return_value_hook int &  return_value  ) 
 

Definition at line 36 of file Resume_Handle.cpp.

References ACE_DEBUG, flag_, LM_DEBUG, TAO_ORB_Core::reactor(), ACE_Reactor::resumable_handler(), TAO_debug_level, TAO_HANDLE_ALREADY_RESUMED, and TAO_HANDLE_LEAVE_SUSPENDED.

Referenced by TAO_Connection_Handler::handle_input_internal().

00037 {
00038   // RT8248: The return value is only changed from 1 to 0 if:
00039   //   1) the handle_input return value wants an immediate callback
00040   //      on the handle (i.e. will return "1")
00041   //   2) this->resume_handle was already called
00042   //   3) reactor->resume_handler was called by this->resume_handle
00043   // The value is changed because you can't ask for an immediate callback
00044   // on a handle that you have already given up ownership of. (RT8248)
00045   if ( return_value == 1 &&
00046        this->flag_ == TAO_HANDLE_ALREADY_RESUMED &&
00047        this->orb_core_ &&
00048        this->orb_core_->reactor ()->resumable_handler () &&
00049        this->handle_ != ACE_INVALID_HANDLE)
00050   {
00051     // a return value of "1" means "call me back immediately;
00052     // but we can't "call me back immediately" on an
00053     // already-resumed handle
00054     return_value = 0;
00055 
00056     if (TAO_debug_level > 6)
00057     {
00058       ACE_DEBUG ((LM_DEBUG,
00059                   "TAO (%P|%t) - Resume_Handle::handle_input_return_value_hook, "
00060                   "overriding return value of 1 with retval = %d\n",
00061                   return_value));
00062     }
00063   }
00064   else if ( return_value == -1 )
00065   {
00066     // this covers the "connection close" case, where you want
00067     // to leave the handle suspended if you're return -1 to
00068     // remove the handle from the Reactor. (See ChangeLog entry
00069     // Fri Dec 16 14:40:54 2005)
00070     this->flag_ = TAO_HANDLE_LEAVE_SUSPENDED;
00071 
00072     if (TAO_debug_level > 6)
00073     {
00074       ACE_DEBUG ((LM_DEBUG,
00075                   "TAO (%P|%t) - Resume_Handle::handle_input_return_value_hook, "
00076                   "handle_input returning -1, so handle is not resumed.\n"));
00077     }
00078   }
00079 }

ACE_INLINE TAO_Resume_Handle & TAO_Resume_Handle::operator= const TAO_Resume_Handle rhs  ) 
 

Assignment operator.

Definition at line 31 of file Resume_Handle.inl.

References flag_, handle_, and orb_core_.

00032 {
00033   this->orb_core_ = rhs.orb_core_;
00034   this->handle_ = rhs.handle_;
00035   this->flag_ = rhs.flag_;
00036 
00037   return *this;
00038 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL void TAO_Resume_Handle::resume_handle void   ) 
 

Resume the handle in the reactor only if the ORB uses a TP reactor. Else we don't resume the handle.

Definition at line 19 of file Resume_Handle.cpp.

References flag_, TAO_ORB_Core::reactor(), ACE_Reactor::resumable_handler(), ACE_Reactor::resume_handler(), TAO_HANDLE_ALREADY_RESUMED, and TAO_HANDLE_RESUMABLE.

Referenced by TAO_Transport::process_parsed_messages(), and ~TAO_Resume_Handle().

00020 {
00021   // If we have a complete message, just resume the handler
00022   // Resume the handler.
00023   if (this->orb_core_ &&
00024       this->orb_core_->reactor ()->resumable_handler () &&
00025       this->flag_ == TAO_HANDLE_RESUMABLE &&
00026       this->handle_ != ACE_INVALID_HANDLE)
00027     {
00028       this->orb_core_->reactor ()->resume_handler (this->handle_);
00029     }
00030 
00031   // Set the flag, so that we dont resume again..
00032   this->flag_ = TAO_HANDLE_ALREADY_RESUMED;
00033 }

ACE_INLINE void TAO_Resume_Handle::set_flag TAO_Handle_Resume_Flag  fl  ) 
 

Allow the users of this class to change the underlying flag.

Definition at line 25 of file Resume_Handle.inl.

References flag_.

Referenced by TAO_Connection_Handler::handle_input_internal(), TAO_Transport::handle_input_parse_data(), TAO_Connection_Handler::handle_output_eh(), and TAO_Transport::process_queue_head().

00026 {
00027   this->flag_ = fl;
00028 }


Member Data Documentation

TAO_Handle_Resume_Flag TAO_Resume_Handle::flag_ [private]
 

The flag for indicating whether the handle has been resumed or not. A value of '0' indicates that the handle needs resumption.

Definition at line 92 of file Resume_Handle.h.

Referenced by handle_input_return_value_hook(), operator=(), resume_handle(), set_flag(), and ~TAO_Resume_Handle().

ACE_HANDLE TAO_Resume_Handle::handle_ [private]
 

The actual handle that needs resumption..

Definition at line 88 of file Resume_Handle.h.

Referenced by operator=().

TAO_ORB_Core* TAO_Resume_Handle::orb_core_ [private]
 

Our ORB Core.

Definition at line 85 of file Resume_Handle.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:23:27 2006 for TAO by doxygen 1.3.6