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 80 of file Asynch_Reply_Dispatcher_Base.cpp.

00081 {
00082 }

void TAO_Asynch_Reply_Dispatcher_Base::decr_refcount void   ) 
 

Definition at line 99 of file Asynch_Reply_Dispatcher_Base.cpp.

References ACE_DES_FREE, and ACE_GUARD.

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

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.

00075 {
00076   return 0;
00077 }

void TAO_Asynch_Reply_Dispatcher_Base::incr_refcount void   ) 
 

Definition at line 90 of file Asynch_Reply_Dispatcher_Base.cpp.

References ACE_GUARD.

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

void TAO_Asynch_Reply_Dispatcher_Base::reply_timed_out void   )  [pure virtual]
 

Inform that the reply timed out.

Definition at line 85 of file Asynch_Reply_Dispatcher_Base.cpp.

00086 {
00087 }

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 126 of file Asynch_Reply_Dispatcher_Base.cpp.

References ACE_GUARD_RETURN, and is_reply_dispatched_.

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


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 135 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 110 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 114 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 131 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 125 of file Asynch_Reply_Dispatcher_Base.h.

CORBA::ULong TAO_Asynch_Reply_Dispatcher_Base::refcount_ [private]
 

Refcount paraphernalia for this class.

Definition at line 128 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 118 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 107 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 121 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 Thu Nov 9 12:12:19 2006 for TAO by doxygen 1.3.6