Public Types | Public Member Functions | Private Attributes

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)
 Constructor.
 ~TAO_Resume_Handle (void)
 Destructor.
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 47 of file Resume_Handle.h.


Member Enumeration Documentation

Enumerator:
TAO_HANDLE_RESUMABLE 
TAO_HANDLE_ALREADY_RESUMED 
TAO_HANDLE_LEAVE_SUSPENDED 

Definition at line 58 of file Resume_Handle.h.

  {
    TAO_HANDLE_RESUMABLE = 0,
    TAO_HANDLE_ALREADY_RESUMED,
    TAO_HANDLE_LEAVE_SUSPENDED
  };


Constructor & Destructor Documentation

TAO_Resume_Handle::TAO_Resume_Handle ( TAO_ORB_Core orb_core = 0,
ACE_HANDLE  h = ACE_INVALID_HANDLE 
)

Constructor.

Definition at line 8 of file Resume_Handle.inl.

  : orb_core_ (orb_core),
    handle_ (h),
    flag_ (TAO_HANDLE_RESUMABLE)
{
}

TAO_Resume_Handle::~TAO_Resume_Handle ( void   ) 

Destructor.

Definition at line 17 of file Resume_Handle.inl.

{
  if (this->flag_ == TAO_HANDLE_RESUMABLE)
    this->resume_handle ();
}


Member Function Documentation

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.

{
  // RT8248: The return value is only changed from 1 to 0 if:
  //   1) the handle_input return value wants an immediate callback
  //      on the handle (i.e. will return "1")
  //   2) this->resume_handle was already called
  //   3) reactor->resume_handler was called by this->resume_handle
  // The value is changed because you can't ask for an immediate callback
  // on a handle that you have already given up ownership of. (RT8248)
  if ( return_value == 1 &&
       this->flag_ == TAO_HANDLE_ALREADY_RESUMED &&
       this->orb_core_ &&
       this->orb_core_->reactor ()->resumable_handler () &&
       this->handle_ != ACE_INVALID_HANDLE)
  {
    // a return value of "1" means "call me back immediately;
    // but we can't "call me back immediately" on an
    // already-resumed handle
    return_value = 0;

    if (TAO_debug_level > 6)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "TAO (%P|%t) - Resume_Handle::handle_input_return_value_hook, "
                  "overriding return value of 1 with retval = %d\n",
                  return_value));
    }
  }
  else if ( return_value == -1 )
  {
    // this covers the "connection close" case, where you want
    // to leave the handle suspended if you're return -1 to
    // remove the handle from the Reactor. (See ChangeLog entry
    // Fri Dec 16 14:40:54 2005)
    this->flag_ = TAO_HANDLE_LEAVE_SUSPENDED;

    if (TAO_debug_level > 6)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "TAO (%P|%t) - Resume_Handle::handle_input_return_value_hook, "
                  "handle_input returning -1, so handle is not resumed.\n"));
    }
  }
}

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

Assignment operator.

Definition at line 31 of file Resume_Handle.inl.

{
  if (this != &rhs)
    {
      this->orb_core_ = rhs.orb_core_;
      this->handle_ = rhs.handle_;
      this->flag_ = rhs.flag_;
    }

  return *this;
}

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.

{
  // If we have a complete message, just resume the handler
  // Resume the handler.
  if (this->orb_core_ &&
      this->orb_core_->reactor ()->resumable_handler () &&
      this->flag_ == TAO_HANDLE_RESUMABLE &&
      this->handle_ != ACE_INVALID_HANDLE)
    {
      this->orb_core_->reactor ()->resume_handler (this->handle_);
    }

  // Set the flag, so that we dont resume again..
  this->flag_ = TAO_HANDLE_ALREADY_RESUMED;
}

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.

{
  this->flag_ = fl;
}


Member Data Documentation

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 90 of file Resume_Handle.h.

ACE_HANDLE TAO_Resume_Handle::handle_ [private]

The actual handle that needs resumption..

Definition at line 86 of file Resume_Handle.h.

Our ORB Core.

Definition at line 83 of file Resume_Handle.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines