summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-11 22:16:58 +0000
committeralex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-11 22:16:58 +0000
commit48f6cf5d99d4eb82919e6dd465dbe889412eea9b (patch)
treebcf764b46d80cf5b335d024c59e01ead7e163c45
parentc88a8d3fa959dcfd9874e700278158eac55f4018 (diff)
downloadATCD-48f6cf5d99d4eb82919e6dd465dbe889412eea9b.tar.gz
ChangeLogTag : Sun Jul 11 14:45:31 1999 Alexander Babu Arulanthu <alex@cs.wustl.edu>
-rw-r--r--TAO/tao/Wait_Strategy.cpp86
-rw-r--r--TAO/tao/Wait_Strategy.h82
-rw-r--r--TAO/tao/default_client.cpp17
3 files changed, 162 insertions, 23 deletions
diff --git a/TAO/tao/Wait_Strategy.cpp b/TAO/tao/Wait_Strategy.cpp
index d781dd66d1e..e9f1904bd76 100644
--- a/TAO/tao/Wait_Strategy.cpp
+++ b/TAO/tao/Wait_Strategy.cpp
@@ -107,7 +107,27 @@ TAO_Wait_On_Reactor::register_handler (void)
// Constructor.
TAO_Wait_On_Leader_Follower::TAO_Wait_On_Leader_Follower (TAO_Transport *transport)
- : TAO_Wait_Strategy (transport),
+ : TAO_Wait_Strategy (transport)
+{
+}
+
+// Destructor.
+TAO_Wait_On_Leader_Follower::~TAO_Wait_On_Leader_Follower (void)
+{
+}
+
+// Register the handler.
+int
+TAO_Wait_On_Leader_Follower::register_handler (void)
+{
+ return this->transport_->register_handler ();
+}
+
+// *********************************************************************
+
+// Constructor.
+TAO_Exclusive_Wait_On_Leader_Follower::TAO_Exclusive_Wait_On_Leader_Follower (TAO_Transport *transport)
+ : TAO_Wait_On_Leader_Follower (transport),
calling_thread_ (ACE_OS::NULL_thread),
cond_response_available_ (0),
expecting_response_ (0),
@@ -116,7 +136,7 @@ TAO_Wait_On_Leader_Follower::TAO_Wait_On_Leader_Follower (TAO_Transport *transpo
}
// Destructor.
-TAO_Wait_On_Leader_Follower::~TAO_Wait_On_Leader_Follower (void)
+TAO_Exclusive_Wait_On_Leader_Follower::~TAO_Exclusive_Wait_On_Leader_Follower (void)
{
delete this->cond_response_available_;
this->cond_response_available_ = 0;
@@ -127,7 +147,7 @@ TAO_Wait_On_Leader_Follower::~TAO_Wait_On_Leader_Follower (void)
// with the <Transport> object and <two_way> flag wont make sense
// at this level since this is common for AMI also. (Alex).
int
-TAO_Wait_On_Leader_Follower::sending_request (TAO_ORB_Core *orb_core,
+TAO_Exclusive_Wait_On_Leader_Follower::sending_request (TAO_ORB_Core *orb_core,
int two_way)
{
{
@@ -172,7 +192,7 @@ TAO_Wait_On_Leader_Follower::sending_request (TAO_ORB_Core *orb_core,
}
int
-TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
+TAO_Exclusive_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
int &)
{
// Cache the ORB core, it won't change and is used multiple times
@@ -214,7 +234,7 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
// wake up multiple times from the CV loop
if (leader_follower.add_follower (cond) == -1)
ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - "
+ "TAO (%P|%t) TAO_Exclusive_Wait_On_Leader_Follower::wait - "
"add_follower failed for <%x>\n",
cond));
@@ -239,7 +259,7 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
countdown.update ();
if (leader_follower.remove_follower (cond) == -1)
ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - "
+ "TAO (%P|%t) TAO_Exclusive_Wait_On_Leader_Follower::wait - "
"remove_follower failed for <%x>\n", cond));
//ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - done (follower:%d) on <%x>\n",
@@ -318,13 +338,13 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
if (leader_follower.elect_new_leader () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "TAO:%N:%l:(%P|%t):TAO_Wait_On_Leader_Follower::send_request: "
+ "TAO:%N:%l:(%P|%t):TAO_Exclusive_Wait_On_Leader_Follower::send_request: "
"Failed to unset the leader and wake up a new follower.\n"),
-1);
if (result == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "TAO:%N:%l:(%P|%t):TAO_Wait_On_Leader_Follower::wait: "
+ "TAO:%N:%l:(%P|%t):TAO_Exclusive_Wait_On_Leader_Follower::wait: "
"handle_events failed.\n"),
-1);
@@ -357,7 +377,7 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
// Handle the input. Return -1 on error, 0 on success.
int
-TAO_Wait_On_Leader_Follower::handle_input (void)
+TAO_Exclusive_Wait_On_Leader_Follower::handle_input (void)
{
TAO_ORB_Core* orb_core =
this->transport_->orb_core ();
@@ -416,15 +436,8 @@ TAO_Wait_On_Leader_Follower::handle_input (void)
return result;
}
-// Register the handler.
-int
-TAO_Wait_On_Leader_Follower::register_handler (void)
-{
- return this->transport_->register_handler ();
-}
-
ACE_SYNCH_CONDITION *
-TAO_Wait_On_Leader_Follower::cond_response_available (void)
+TAO_Exclusive_Wait_On_Leader_Follower::cond_response_available (void)
{
// @@ TODO This condition variable should per-ORB-per-thread, not
// per-connection, it is a waste to have more than one of this in
@@ -441,7 +454,7 @@ TAO_Wait_On_Leader_Follower::cond_response_available (void)
}
void
-TAO_Wait_On_Leader_Follower::wake_up (void)
+TAO_Exclusive_Wait_On_Leader_Follower::wake_up (void)
{
if (ACE_OS::thr_equal (this->calling_thread_, ACE_Thread::self ()))
{
@@ -467,6 +480,43 @@ TAO_Wait_On_Leader_Follower::wake_up (void)
// *********************************************************************
// Constructor.
+TAO_Muxed_Wait_On_Leader_Follower::TAO_Muxed_Wait_On_Leader_Follower (TAO_Transport *transport)
+ : TAO_Wait_On_Leader_Follower (transport)
+{
+}
+
+// Destructor.
+TAO_Muxed_Wait_On_Leader_Follower::~TAO_Muxed_Wait_On_Leader_Follower (void)
+{
+}
+
+// @@ Why do we need <orb_core> and the <two_way> flag? <orb_core> is
+// with the <Transport> object and <two_way> flag wont make sense
+// at this level since this is common for AMI also. (Alex).
+int
+TAO_Muxed_Wait_On_Leader_Follower::sending_request (TAO_ORB_Core *orb_core,
+ int two_way)
+{
+ return 0;
+}
+
+int
+TAO_Muxed_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time,
+ int &reply_received)
+{
+ return 0;
+}
+
+// Handle the input. Return -1 on error, 0 on success.
+int
+TAO_Muxed_Wait_On_Leader_Follower::handle_input (void)
+{
+ return 0;
+}
+
+// *********************************************************************
+
+// Constructor.
TAO_Wait_On_Read::TAO_Wait_On_Read (TAO_Transport *transport)
: TAO_Wait_Strategy (transport)
{
diff --git a/TAO/tao/Wait_Strategy.h b/TAO/tao/Wait_Strategy.h
index d32d72e605d..8eaa4b15d30 100644
--- a/TAO/tao/Wait_Strategy.h
+++ b/TAO/tao/Wait_Strategy.h
@@ -69,6 +69,8 @@ protected:
// that can minimize the footprint of systems that use only one of
// the strategies....
+// *********************************************************************
+
class TAO_Export TAO_Wait_On_Reactor : public TAO_Wait_Strategy
{
// = TITLE
@@ -99,6 +101,8 @@ private:
// to exit the event loop.
};
+// *********************************************************************
+
class TAO_Export TAO_Wait_On_Leader_Follower : public TAO_Wait_Strategy
{
// = TITLE
@@ -116,7 +120,45 @@ public:
virtual ~TAO_Wait_On_Leader_Follower (void);
// Destructor.
+
+ // = Documented in TAO_Wait_Strategy.
+
+ // virtual int sending_request (TAO_ORB_Core *orb_core,
+ // int two_way);
+
+ // virtual int wait (ACE_Time_Value *max_wait_time,
+ // int &reply_received);
+
+ // virtual int handle_input (void);
+
+ virtual int register_handler (void);
+};
+
+// *********************************************************************
+class TAO_Export TAO_Exclusive_Wait_On_Leader_Follower : public TAO_Wait_On_Leader_Follower
+{
+ // = TITLE
+ //
+ // Wait according to the Leader-Follower model. Leader does the
+ // event loop of the Reactor and the Followers wait on the
+ // condition variable.
+ //
+ // = DESCRIPTION
+ //
+ // This is strategy is to work with the Exclusive Transport Mux
+ // Strategy. This was the original implementation of Leader
+ // Follower before Muxed Transport was introduced. Here the
+ // state variables such as Condition Variable etc are kept in
+ // the <Wait Strategy> which is a per Transport object.
+
+public:
+ TAO_Exclusive_Wait_On_Leader_Follower (TAO_Transport *transport);
+ // Constructor.
+
+ virtual ~TAO_Exclusive_Wait_On_Leader_Follower (void);
+ // Destructor.
+
// = Documented in TAO_Wait_Strategy.
virtual int sending_request (TAO_ORB_Core *orb_core,
@@ -124,7 +166,7 @@ public:
virtual int wait (ACE_Time_Value *max_wait_time,
int &reply_received);
virtual int handle_input (void);
- virtual int register_handler (void);
+ // virtual int register_handler (void);
protected:
ACE_SYNCH_CONDITION* cond_response_available (void);
@@ -151,6 +193,44 @@ protected:
// or the reactor event loop.
};
+// *********************************************************************
+
+class TAO_Export TAO_Muxed_Wait_On_Leader_Follower : public TAO_Wait_On_Leader_Follower
+{
+ // = TITLE
+ //
+ // Wait according to the Leader-Follower model. Leader does the
+ // event loop of the Reactor and the Followers wait on the
+ // condition variable.
+ //
+ // = DESCRIPTION
+ //
+ // This impelementation is to work with the Muxed Transport
+ // Mechanism. Here the state variables such as <Condition
+ // Variable> etc cannot be kept in the Wait Strategy, since the
+ // Wait Strategy is per Transport object and here the Transport
+ // is Muxed and hence there are multiple threads running in the
+ // same Transport context.
+
+public:
+ TAO_Muxed_Wait_On_Leader_Follower (TAO_Transport *transport);
+ // Constructor.
+
+ virtual ~TAO_Muxed_Wait_On_Leader_Follower (void);
+ // Destructor.
+
+ // = Documented in TAO_Wait_Strategy.
+
+ virtual int sending_request (TAO_ORB_Core *orb_core,
+ int two_way);
+ virtual int wait (ACE_Time_Value *max_wait_time,
+ int &reply_received);
+ virtual int handle_input (void);
+ // virtual int register_handler (void);
+};
+
+// *********************************************************************
+
class TAO_Export TAO_Wait_On_Read : public TAO_Wait_Strategy
{
// = TITLE
diff --git a/TAO/tao/default_client.cpp b/TAO/tao/default_client.cpp
index 3325ac7a5c2..56052fb4a3b 100644
--- a/TAO/tao/default_client.cpp
+++ b/TAO/tao/default_client.cpp
@@ -187,10 +187,19 @@ TAO_Default_Client_Strategy_Factory::create_wait_strategy (TAO_Transport *transp
TAO_Wait_On_Reactor (transport),
0);
else
- ACE_NEW_RETURN (ws,
- TAO_Wait_On_Leader_Follower (transport),
- 0);
-
+ {
+ // = Leader follower model.
+
+ if (this->transport_mux_strategy_ == TAO_EXCLUSIVE_TMS)
+ ACE_NEW_RETURN (ws,
+ TAO_Exclusive_Wait_On_Leader_Follower (transport),
+ 0);
+ else
+ ACE_NEW_RETURN (ws,
+ TAO_Muxed_Wait_On_Leader_Follower (transport),
+ 0);
+ }
+
return ws;
}