#include <Resume_Handle.h>
Collaboration diagram for TAO_Resume_Handle:
Public Types | |
TAO_HANDLE_RESUMABLE = 0 | |
TAO_HANDLE_ALREADY_RESUMED | |
TAO_HANDLE_LEAVE_SUSPENDED | |
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_Handle & | operator= (const TAO_Resume_Handle &rhs) |
Assignment operator. | |
void | resume_handle (void) |
void | handle_input_return_value_hook (int &return_value) |
Private Attributes | |
TAO_ORB_Core * | orb_core_ |
Our ORB Core. | |
ACE_HANDLE | handle_ |
The actual handle that needs resumption.. | |
TAO_Handle_Resume_Flag | flag_ |
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.
Definition at line 59 of file Resume_Handle.h.
00060 { 00061 TAO_HANDLE_RESUMABLE = 0, 00062 TAO_HANDLE_ALREADY_RESUMED, 00063 TAO_HANDLE_LEAVE_SUSPENDED 00064 };
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 resume_handle(), and TAO_HANDLE_RESUMABLE.
00018 { 00019 if (this->flag_ == TAO_HANDLE_RESUMABLE) 00020 this->resume_handle (); 00021 }
void TAO_Resume_Handle::handle_input_return_value_hook | ( | int & | return_value | ) |
Hook method called at the end of a connection handler's handle_input function. Might override the handle_input return value or change the resume_handler's flag_ value.
Definition at line 36 of file Resume_Handle.cpp.
References ACE_DEBUG, flag_, handle_, LM_DEBUG, TAO_debug_level, TAO_HANDLE_ALREADY_RESUMED, and TAO_HANDLE_LEAVE_SUSPENDED.
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 | ) |
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.
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_Transport::handle_input_parse_data(), and TAO_Transport::process_queue_head().
00026 { 00027 this->flag_ = fl; 00028 }
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 91 of file Resume_Handle.h.
Referenced by handle_input_return_value_hook(), operator=(), and set_flag().
ACE_HANDLE TAO_Resume_Handle::handle_ [private] |
The actual handle that needs resumption..
Definition at line 87 of file Resume_Handle.h.
Referenced by handle_input_return_value_hook(), and operator=().
TAO_ORB_Core* TAO_Resume_Handle::orb_core_ [private] |