summaryrefslogtreecommitdiff
path: root/TAO/tao/Asynch_Reply_Dispatcher_Base.h
diff options
context:
space:
mode:
authorbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-12-07 06:03:29 +0000
committerbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-12-07 06:03:29 +0000
commit9d5b6f4e33cfaced5734323bf93d9dda473c76e8 (patch)
tree9b758c90c73ba2f1d690edc4dd4c25fb18989948 /TAO/tao/Asynch_Reply_Dispatcher_Base.h
parentb062fe17a1df3851bf0109193c0631c4ed838400 (diff)
downloadATCD-9d5b6f4e33cfaced5734323bf93d9dda473c76e8.tar.gz
ChangeLogTag:Sat Dec 6 23:42:13 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/tao/Asynch_Reply_Dispatcher_Base.h')
-rw-r--r--TAO/tao/Asynch_Reply_Dispatcher_Base.h92
1 files changed, 78 insertions, 14 deletions
diff --git a/TAO/tao/Asynch_Reply_Dispatcher_Base.h b/TAO/tao/Asynch_Reply_Dispatcher_Base.h
index e5f80b202df..4857cdb3bc8 100644
--- a/TAO/tao/Asynch_Reply_Dispatcher_Base.h
+++ b/TAO/tao/Asynch_Reply_Dispatcher_Base.h
@@ -27,35 +27,62 @@ class TAO_Pluggable_Reply_Params;
class TAO_ORB_Core ;
class ACE_Time_Value;
class TAO_Transport;
+class ACE_Lock;
-/// Base class for TAO_Asynch_Reply_Dispatcher and
-/// TAO_DII_Deferred_Reply_Dispatcher
-class TAO_Export TAO_Asynch_Reply_Dispatcher_Base
+/**
+ * @class TAO_Asynch_Reply_Dispatcher_Base
+ *
+ * @brief Base class for TAO_Asynch_Reply_Dispatcher and
+ * TAO_DII_Deferred_Reply_Dispatcher
+ */
+
+class TAO_Export TAO_Asynch_Reply_Dispatcher_Base
: public TAO_Reply_Dispatcher
{
public:
/// Default constructor.
TAO_Asynch_Reply_Dispatcher_Base (TAO_ORB_Core *orb_core);
- /// Destructor.
- virtual ~TAO_Asynch_Reply_Dispatcher_Base (void);
-
/// Sets the transport for this invocation.
void transport (TAO_Transport *t);
// = The Reply Dispatcher methods
- virtual int dispatch_reply (TAO_Pluggable_Reply_Params &params);
-
- // virtual TAO_GIOP_Message_State *message_state (void);
+ virtual int dispatch_reply (TAO_Pluggable_Reply_Params &) = 0;
- virtual void connection_closed (void);
+ virtual void connection_closed (void) = 0;
- /// Inform that the reply timed out
- virtual void reply_timed_out (void);
+ /// Inform that the reply timed out
+ virtual void reply_timed_out (void) = 0;
/// Install the timeout handler
- virtual long schedule_timer (CORBA::ULong request_id,
- const ACE_Time_Value &max_wait_time);
+ virtual long schedule_timer (CORBA::ULong ,
+ const ACE_Time_Value &)= 0;
+
+ /// Mutators for refcount
+ long incr_refcount (void);
+ long decr_refcount (void);
+
+ /// A helper method that can be used by the sublcasses
+ /**
+ * 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?
+ */
+ bool try_dispatch_reply (void);
+
+protected:
+
+ /// Destructor.
+ virtual ~TAO_Asynch_Reply_Dispatcher_Base (void);
protected:
/// The service context list.
@@ -80,8 +107,45 @@ protected:
/// This invocation is using this transport, may change...
TAO_Transport *transport_;
+
+private:
+ /// Lock to protect recount and <is_reply_dispatched_> flag.
+ ACE_Lock *lock_;
+
+ /// Refcount paraphernalia for this class
+ long refcount_;
+
+ /// Has the reply been dispatched?
+ bool is_reply_dispatched_;
};
+namespace TAO
+{
+ /**
+ * @class ARDB_Refcount_Functor
+ *
+ * @brief Functor for refcounting of Asynch_Reply_Dispatcher_Base
+ *
+ * This is used to safely handle the destruction of
+ * Asynch_Reply_Dispatcher_Base objects which are created on the
+ * heap. We cannot use auto_ptr <> since it calls delete on the
+ * pointer, and calling delete on Asynch_Reply_Dispatcher_Base *
+ * will not work. Hence this functor will be used with Auto_Functor
+ * class to handle the memory safely.
+ *
+ * @TODO: Ideally, this class can be a generic class. But that
+ * requires quite a bit of cleanup within TAO to be more useful.
+ */
+ class ARDB_Refcount_Functor
+ {
+ public:
+ void operator() (TAO_Asynch_Reply_Dispatcher_Base *ardb
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC (());
+ };
+
+}
+
#if defined (__ACE_INLINE__)
#include "tao/Asynch_Reply_Dispatcher_Base.i"
#endif /* __ACE_INLINE__ */