TAO_Asynch_Reply_Dispatcher_Base Class Reference

Base class for TAO_Asynch_Reply_Dispatcher and TAO_DII_Deferred_Reply_Dispatcher. More...

#include <Asynch_Reply_Dispatcher_Base.h>

Inheritance diagram for TAO_Asynch_Reply_Dispatcher_Base:

Inheritance graph
[legend]
Collaboration diagram for TAO_Asynch_Reply_Dispatcher_Base:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Asynch_Reply_Dispatcher_Base (TAO_ORB_Core *orb_core, ACE_Allocator *allocator=0)
 Default constructor.

void transport (TAO_Transport *t)
 Sets the transport for this invocation.

virtual void reply_timed_out (void)=0
 Inform that the reply timed out.

virtual long schedule_timer (CORBA::ULong, const ACE_Time_Value &)=0
 Install the timeout handler.

bool try_dispatch_reply (void)
 A helper method that can be used by the subclasses.

The Reply Dispatcher methods
virtual int dispatch_reply (TAO_Pluggable_Reply_Params &)=0
virtual void connection_closed (void)=0
Mutators for refcount
void incr_refcount (void)
void decr_refcount (void)

Protected Member Functions

virtual ~TAO_Asynch_Reply_Dispatcher_Base (void)
 Destructor.


Protected Attributes

IOP::ServiceContextList reply_service_info_
 The service context list.

char buf_ [ACE_CDR::DEFAULT_BUFSIZE]
 The buffer that is used to initialise the data block.

ACE_Data_Block db_
TAO_InputCDR reply_cdr_
TAO_Transporttransport_
 This invocation is using this transport, may change...


Private Attributes

ACE_Locklock_
 Lock to protect refcount and is_reply_dispatched_ flag.

CORBA::ULong refcount_
 Refcount paraphernalia for this class.

bool is_reply_dispatched_
 Has the reply been dispatched?

ACE_Allocatorallocator_

Detailed Description

Base class for TAO_Asynch_Reply_Dispatcher and TAO_DII_Deferred_Reply_Dispatcher.

Definition at line 45 of file Asynch_Reply_Dispatcher_Base.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Asynch_Reply_Dispatcher_Base::TAO_Asynch_Reply_Dispatcher_Base TAO_ORB_Core orb_core,
ACE_Allocator allocator = 0
 

Default constructor.

Definition at line 20 of file Asynch_Reply_Dispatcher_Base.cpp.

References TAO_Resource_Factory::create_cached_connection_lock(), TAO_ORB_Core::resource_factory(), TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_ENCAP_BYTE_ORDER.

00024   : db_ (sizeof buf_,
00025          ACE_Message_Block::MB_DATA,
00026          this->buf_,
00027          orb_core->input_cdr_buffer_allocator (),
00028          orb_core->locking_strategy (),
00029          ACE_Message_Block::DONT_DELETE,
00030          orb_core->input_cdr_dblock_allocator ()),
00031     reply_cdr_ (&db_,
00032                 ACE_Message_Block::MB_DATA,
00033                 TAO_ENCAP_BYTE_ORDER,
00034                 TAO_DEF_GIOP_MAJOR,
00035                 TAO_DEF_GIOP_MINOR,
00036                 orb_core)
00037   , transport_ (0)
00038   , lock_ (0)
00039   , refcount_ (1)
00040   , is_reply_dispatched_ (false)
00041   , allocator_ (allocator)
00042 {
00043   // @@ NOTE: Need a seperate option for this..
00044   this->lock_ =
00045     orb_core->resource_factory ()->create_cached_connection_lock ();
00046 }

TAO_Asynch_Reply_Dispatcher_Base::~TAO_Asynch_Reply_Dispatcher_Base void   )  [protected, virtual]
 

Destructor.

Definition at line 49 of file Asynch_Reply_Dispatcher_Base.cpp.

References TAO_Transport::remove_reference(), and transport_.

00050 {
00051   // Release the transport that we own
00052   if (this->transport_ != 0)
00053     this->transport_->remove_reference ();
00054 
00055   if (this->lock_)
00056     delete this->lock_;
00057 }


Member Function Documentation

void TAO_Asynch_Reply_Dispatcher_Base::connection_closed void   )  [pure virtual]
 

The used for the pending reply has been closed. No reply is expected.

Todo:
If the connection was closed due to a CloseConnection message then we could re-issue the request instead of raising the exception, it would a matter of simply adding a boolean argument to this function.

Implements TAO_Reply_Dispatcher.

Definition at line 79 of file Asynch_Reply_Dispatcher_Base.cpp.

00080 {
00081 }

void TAO_Asynch_Reply_Dispatcher_Base::decr_refcount void   ) 
 

Definition at line 98 of file Asynch_Reply_Dispatcher_Base.cpp.

References ACE_DES_FREE, and ACE_GUARD.

00099 {
00100   {
00101     ACE_GUARD (ACE_Lock,
00102                mutex,
00103                *this->lock_);
00104     --this->refcount_;
00105 
00106     if (this->refcount_ > 0)
00107       return;
00108   }
00109 
00110   if (this->allocator_)
00111     {
00112       ACE_DES_FREE (this,
00113                     this->allocator_->free,
00114                     TAO_Asynch_Reply_Dispatcher_Base);
00115     }
00116   else
00117     {
00118       delete this;
00119     }
00120 
00121   return;
00122 }

int TAO_Asynch_Reply_Dispatcher_Base::dispatch_reply TAO_Pluggable_Reply_Params  )  [pure virtual]
 

Dispatch the reply. Return 1 on sucess, -1 on error.

Todo:
Pluggable Messaging: this method has too many arguments, the "Right Thing"[tm] is for the Transport Object to create a "ClientReply" that encapsulates all we need to process a reply. Naturally it is possible that different messaging protocols implement different variants of such ClientReply class.

Implements TAO_Reply_Dispatcher.

Definition at line 72 of file Asynch_Reply_Dispatcher_Base.cpp.

00074 {
00075   return 0;
00076 }

void TAO_Asynch_Reply_Dispatcher_Base::incr_refcount void   ) 
 

Definition at line 89 of file Asynch_Reply_Dispatcher_Base.cpp.

References ACE_GUARD.

00090 {
00091   ACE_GUARD (ACE_Lock,
00092              mutex,
00093              *this->lock_);
00094   ++this->refcount_;
00095 }

void TAO_Asynch_Reply_Dispatcher_Base::reply_timed_out void   )  [pure virtual]
 

Inform that the reply timed out.

Definition at line 84 of file Asynch_Reply_Dispatcher_Base.cpp.

00085 {
00086 }

virtual long TAO_Asynch_Reply_Dispatcher_Base::schedule_timer CORBA::ULong  ,
const ACE_Time_Value
[pure virtual]
 

Install the timeout handler.

void TAO_Asynch_Reply_Dispatcher_Base::transport TAO_Transport t  ) 
 

Sets the transport for this invocation.

Definition at line 60 of file Asynch_Reply_Dispatcher_Base.cpp.

References TAO_Transport::add_reference(), TAO_Transport::remove_reference(), and transport_.

00061 {
00062   if (this->transport_ != 0)
00063     this->transport_->remove_reference ();
00064 
00065   this->transport_ = t;
00066 
00067   this->transport_->add_reference ();
00068 }

bool TAO_Asynch_Reply_Dispatcher_Base::try_dispatch_reply void   ) 
 

A helper method that can be used by the subclasses.

The semantics of this helper method needs careful attention. A call to this method will do the following

  • If the reply has already been dispatched, the return value will be false to signify not to try.

  • If the reply has not been dispatched, this method will set the flag to be true and return a true value to signify that the caller thread can go ahead and dispatch reply.

Why are we clumping everything in one method. Answer is we need atomicity?

Definition at line 125 of file Asynch_Reply_Dispatcher_Base.cpp.

References ACE_GUARD_RETURN, and is_reply_dispatched_.

00126 {
00127   if (this->is_reply_dispatched_)
00128     {
00129       return false;
00130     }
00131   else
00132     {
00133       ACE_GUARD_RETURN (ACE_Lock,
00134                         mutex,
00135                         *this->lock_,
00136                         false);
00137 
00138       if (!this->is_reply_dispatched_)
00139         {
00140           this->is_reply_dispatched_ = true;
00141           return true;
00142         }
00143     }
00144 
00145   return false;
00146 }


Member Data Documentation

ACE_Allocator* TAO_Asynch_Reply_Dispatcher_Base::allocator_ [private]
 

Allocator that was used to allocate this reply dispatcher. In case of zero we come from the heap.

Definition at line 133 of file Asynch_Reply_Dispatcher_Base.h.

char TAO_Asynch_Reply_Dispatcher_Base::buf_[ACE_CDR::DEFAULT_BUFSIZE] [protected]
 

The buffer that is used to initialise the data block.

Definition at line 108 of file Asynch_Reply_Dispatcher_Base.h.

ACE_Data_Block TAO_Asynch_Reply_Dispatcher_Base::db_ [protected]
 

Datablock that is created on the stack to initialise the CDR stream underneath.

Definition at line 112 of file Asynch_Reply_Dispatcher_Base.h.

bool TAO_Asynch_Reply_Dispatcher_Base::is_reply_dispatched_ [private]
 

Has the reply been dispatched?

Definition at line 129 of file Asynch_Reply_Dispatcher_Base.h.

Referenced by try_dispatch_reply().

ACE_Lock* TAO_Asynch_Reply_Dispatcher_Base::lock_ [private]
 

Lock to protect refcount and is_reply_dispatched_ flag.

Definition at line 123 of file Asynch_Reply_Dispatcher_Base.h.

CORBA::ULong TAO_Asynch_Reply_Dispatcher_Base::refcount_ [private]
 

Refcount paraphernalia for this class.

Definition at line 126 of file Asynch_Reply_Dispatcher_Base.h.

TAO_InputCDR TAO_Asynch_Reply_Dispatcher_Base::reply_cdr_ [protected]
 

CDR stream which has the reply information that needs to be demarshalled by the stubs

Definition at line 116 of file Asynch_Reply_Dispatcher_Base.h.

IOP::ServiceContextList TAO_Asynch_Reply_Dispatcher_Base::reply_service_info_ [protected]
 

The service context list.

Note, that this is not a reference as in the synchronous case. We own the reply_service_info because our TAO_Asynch_Invocation or TAO_DII_Deferred_Invocation will go out of scope before we are done.

Definition at line 105 of file Asynch_Reply_Dispatcher_Base.h.

TAO_Transport* TAO_Asynch_Reply_Dispatcher_Base::transport_ [protected]
 

This invocation is using this transport, may change...

Definition at line 119 of file Asynch_Reply_Dispatcher_Base.h.

Referenced by transport(), and ~TAO_Asynch_Reply_Dispatcher_Base().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:14:02 2008 for TAO by doxygen 1.3.6