summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2002-04-23 17:24:10 +0000
committerbala <balanatarajan@users.noreply.github.com>2002-04-23 17:24:10 +0000
commit0e7eef4ae37bd1772295dfef448838d83da19577 (patch)
tree16fefcc3c2f133dce1ee5637861afdd3e33f6e5e
parent44ae442f84fc9b8fca656e6fc96216c6ca0c5c1e (diff)
downloadATCD-0e7eef4ae37bd1772295dfef448838d83da19577.tar.gz
ChangeLogTag:Mon Apr 22 13:21:05 2002 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r--TAO/tao/Blocked_Connect_Strategy.cpp46
-rw-r--r--TAO/tao/Blocked_Connect_Strategy.h53
-rw-r--r--TAO/tao/Connect_Strategy.cpp14
-rw-r--r--TAO/tao/Connect_Strategy.h76
-rw-r--r--TAO/tao/LF_Connect_Strategy.cpp68
-rw-r--r--TAO/tao/LF_Connect_Strategy.h56
-rw-r--r--TAO/tao/Reactive_Connect_Strategy.cpp77
-rw-r--r--TAO/tao/Reactive_Connect_Strategy.h55
8 files changed, 445 insertions, 0 deletions
diff --git a/TAO/tao/Blocked_Connect_Strategy.cpp b/TAO/tao/Blocked_Connect_Strategy.cpp
new file mode 100644
index 00000000000..431f3ab424b
--- /dev/null
+++ b/TAO/tao/Blocked_Connect_Strategy.cpp
@@ -0,0 +1,46 @@
+#include "Blocked_Connect_Strategy.h"
+#include "ace/Synch_Options.h"
+
+
+ACE_RCSID(tao,
+ Blocked_Connect_Strategy,
+ "$Id$")
+
+
+TAO_Blocked_Connect_Strategy::TAO_Blocked_Connect_Strategy (
+ TAO_ORB_Core *orb_core)
+ : TAO_Connect_Strategy (orb_core)
+{
+}
+
+TAO_Blocked_Connect_Strategy::~TAO_Blocked_Connect_Strategy (void)
+{
+}
+
+
+void
+TAO_Blocked_Connect_Strategy::synch_options (ACE_Time_Value *timeout,
+ ACE_Synch_Options &options)
+{
+ if (timeout != 0)
+ {
+ // Blocking with a timeout
+ options.set (ACE_Synch_Options::USE_TIMEOUT,
+ *timeout);
+ }
+ else
+ {
+ // Making it sure it is blocking.
+ options.set (0,
+ ACE_Time_Value::zero);
+ }
+}
+
+
+int
+TAO_Blocked_Connect_Strategy::wait (TAO_Connection_Handler *,
+ ACE_Time_Value * )
+{
+ // We cannot wait for connection completion
+ return -1;
+}
diff --git a/TAO/tao/Blocked_Connect_Strategy.h b/TAO/tao/Blocked_Connect_Strategy.h
new file mode 100644
index 00000000000..a5564fda18e
--- /dev/null
+++ b/TAO/tao/Blocked_Connect_Strategy.h
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Blocked_Connect_Strategy.h
+ *
+ * $Id$
+ *
+ * @author Balachandran Natarajan <bala@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_BLOCKED_CONNECT_STRATEGY_H
+#define TAO_BLOCKED_CONNECT_STRATEGY_H
+#include "ace/pre.h"
+
+#include "Connect_Strategy.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+/**
+ * @class TAO_Blocked_Connect_Strategy
+ *
+ * @brief Concrete implementation of a connect strategy that blocks
+ * during connects
+ *
+ */
+
+class TAO_Export TAO_Blocked_Connect_Strategy : public TAO_Connect_Strategy
+{
+public:
+ /// Contructor
+ TAO_Blocked_Connect_Strategy (TAO_ORB_Core *orb);
+
+ /// Destructor
+ ~TAO_Blocked_Connect_Strategy (void);
+
+ /*
+ * Concrete implementation for this class. Please see
+ * Connect_Strategy.h for details
+ */
+ virtual void synch_options (ACE_Time_Value *val,
+ ACE_Synch_Options &opt);
+
+ virtual int wait (TAO_Connection_Handler *ch,
+ ACE_Time_Value *val);
+};
+
+
+
+#endif /*TAO_BLOCKED_CONNECT_STRATEGY_H*/
diff --git a/TAO/tao/Connect_Strategy.cpp b/TAO/tao/Connect_Strategy.cpp
new file mode 100644
index 00000000000..d4b04328118
--- /dev/null
+++ b/TAO/tao/Connect_Strategy.cpp
@@ -0,0 +1,14 @@
+#include "Connect_Strategy.h"
+
+
+ACE_RCSID(tao, Connect_Strategy, "$Id$")
+
+TAO_Connect_Strategy::TAO_Connect_Strategy (TAO_ORB_Core *orb_core)
+ : orb_core_ (orb_core)
+{
+}
+
+
+TAO_Connect_Strategy::~TAO_Connect_Strategy (void)
+{
+}
diff --git a/TAO/tao/Connect_Strategy.h b/TAO/tao/Connect_Strategy.h
new file mode 100644
index 00000000000..000198a083e
--- /dev/null
+++ b/TAO/tao/Connect_Strategy.h
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Connect_Strategy.h
+ *
+ * $Id$
+ *
+ * @author Balachandran Natarajan <bala@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_CONNECT_STRATEGY_H
+#define TAO_CONNECT_STRATEGY_H
+#include "ace/pre.h"
+
+#include "TAO_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+class TAO_ORB_Core;
+class TAO_Connector;
+class TAO_Connection_Handler;
+class ACE_Synch_Options;
+class ACE_Time_Value;
+
+/**
+ * @class TAO_Connect_Strategy
+ *
+ * @brief Define the interface for the connect strategy, i.e. the
+ * algorithm that controls how does the ORB establishes remote
+ * connections.
+ *
+ * The thread that establishes remote connections can either make a
+ * blocking or a non-blocking connect. The strategy to wait for the
+ * connection completion can also be different.
+ *
+ * This strategy controls how does the ORB schedules and waits for
+ * connection completion.
+ */
+
+class TAO_Export TAO_Connect_Strategy
+{
+public:
+
+ /// Constructor
+ TAO_Connect_Strategy (TAO_ORB_Core *orb);
+
+ /// Destructor
+ virtual ~TAO_Connect_Strategy (void);
+
+ /* Return the synch option for the connector, based on the timeout
+ * and the strategy in place. ACE_Connectors behavior can be altered
+ * by passing the right ACE_Synch_Options to the connect () call.
+ */
+ virtual void synch_options (ACE_Time_Value *val,
+ ACE_Synch_Options &opt) = 0;
+
+ /* Wait for the connection to be completed and return a transport
+ * whose reference count has been incremented. If the connection
+ * establishment fails this method returns a null transport
+ * indicating the failure of connection.
+ */
+ virtual int wait (TAO_Connection_Handler *ch,
+ ACE_Time_Value *val) = 0;
+protected:
+
+ /// Cached copy of the ORB core pointer
+ TAO_ORB_Core *orb_core_;
+};
+
+
+
+#endif /*TAO_CONNECT_STRATEGY_H*/
diff --git a/TAO/tao/LF_Connect_Strategy.cpp b/TAO/tao/LF_Connect_Strategy.cpp
new file mode 100644
index 00000000000..7a398e1715c
--- /dev/null
+++ b/TAO/tao/LF_Connect_Strategy.cpp
@@ -0,0 +1,68 @@
+#include "LF_Connect_Strategy.h"
+#include "Connection_Handler.h"
+#include "Transport.h"
+#include "ORB_Core.h"
+#include "LF_Event.h"
+#include "Leader_Follower.h"
+#include "ace/Synch_Options.h"
+
+
+ACE_RCSID(tao,
+ LF_Connect_Strategy,
+ "$Id$")
+
+
+TAO_LF_Connect_Strategy::TAO_LF_Connect_Strategy (
+ TAO_ORB_Core *orb_core)
+ : TAO_Connect_Strategy (orb_core)
+{
+}
+
+TAO_LF_Connect_Strategy::~TAO_LF_Connect_Strategy (void)
+{
+}
+
+void
+TAO_LF_Connect_Strategy::synch_options (ACE_Time_Value *timeout,
+ ACE_Synch_Options &options)
+{
+ if (timeout != 0)
+ {
+ options.set (ACE_Synch_Options::USE_REACTOR,
+ *timeout);
+ }
+ else
+ {
+ // Making it sure it is blocking.
+ options.set (ACE_Synch_Options::USE_REACTOR,
+ ACE_Time_Value::zero);
+ }
+}
+
+
+int
+TAO_LF_Connect_Strategy::wait (TAO_Connection_Handler *ch,
+ ACE_Time_Value *max_wait_time)
+{
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_LIB_TEXT ("(%P|%t) Waiting on the LF for")
+ ACE_LIB_TEXT (" connection completion - wait () \n")));
+
+ TAO_Transport *transport =
+ ch->transport ();
+
+ TAO_Leader_Follower &leader_follower =
+ transport->orb_core ()->leader_follower ();
+
+ int result =
+ leader_follower.wait_for_event (ch,
+ transport,
+ max_wait_time);
+
+ // Set the result.
+ if (!ch->successful () && result != -1)
+ result = -1;
+
+ return result;
+}
diff --git a/TAO/tao/LF_Connect_Strategy.h b/TAO/tao/LF_Connect_Strategy.h
new file mode 100644
index 00000000000..80cb3280e66
--- /dev/null
+++ b/TAO/tao/LF_Connect_Strategy.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Leader_Follower_Connect_Strategy.h
+ *
+ * $Id$
+ *
+ * @author Balachandran Natarajan <bala@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_LF_CONNECT_STRATEGY_H
+#define TAO_LF_CONNECT_STRATEGY_H
+#include "ace/pre.h"
+
+#include "Connect_Strategy.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+class TAO_Connector;
+class ACE_Time_Value;
+class ACE_Synch_Options;
+
+/**
+ * @class TAO_LF_Connect_Strategy
+ *
+ * @brief Concrete implementation of a connect strategy that waits on
+ * the leader-follower during asynch connects
+ */
+
+class TAO_Export TAO_LF_Connect_Strategy : public TAO_Connect_Strategy
+{
+public:
+ /// Constructor
+ TAO_LF_Connect_Strategy (TAO_ORB_Core *orb);
+
+ /// Destructor
+ ~TAO_LF_Connect_Strategy (void);
+
+ /*
+ * Concrete implementation for this class. Please see
+ * Connect_Strategy.h for details
+ */
+ virtual void synch_options (ACE_Time_Value *val,
+ ACE_Synch_Options &opt);
+
+ virtual int wait (TAO_Connection_Handler *ch,
+ ACE_Time_Value *val);
+};
+
+
+
+#endif /*TAO_LF_CONNECT_STRATEGY_H*/
diff --git a/TAO/tao/Reactive_Connect_Strategy.cpp b/TAO/tao/Reactive_Connect_Strategy.cpp
new file mode 100644
index 00000000000..95929a7d2f3
--- /dev/null
+++ b/TAO/tao/Reactive_Connect_Strategy.cpp
@@ -0,0 +1,77 @@
+#include "Reactive_Connect_Strategy.h"
+#include "Connection_Handler.h"
+#include "Transport.h"
+#include "ORB_Core.h"
+#include "ace/Synch_Options.h"
+
+ACE_RCSID(tao,
+ Reactive_Connect_Strategy,
+ "$Id$")
+
+
+TAO_Reactive_Connect_Strategy::TAO_Reactive_Connect_Strategy (
+ TAO_ORB_Core *orb_core)
+ : TAO_Connect_Strategy (orb_core)
+{
+}
+
+TAO_Reactive_Connect_Strategy::~TAO_Reactive_Connect_Strategy (void)
+{
+}
+
+void
+TAO_Reactive_Connect_Strategy::synch_options (ACE_Time_Value *timeout,
+ ACE_Synch_Options &options)
+{
+ if (timeout != 0)
+ {
+ options.set (ACE_Synch_Options::USE_REACTOR,
+ *timeout);
+ }
+ else
+ {
+ // Making it sure it is blocking.
+ options.set (ACE_Synch_Options::USE_REACTOR,
+ ACE_Time_Value::zero);
+ }
+}
+
+
+int
+TAO_Reactive_Connect_Strategy::wait (TAO_Connection_Handler *ch,
+ ACE_Time_Value *max_wait_time)
+{
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_LIB_TEXT ("(%P|%t) Waiting in the Reactor for")
+ ACE_LIB_TEXT (" connection completion - wait () \n")));
+
+ TAO_Transport *transport =
+ ch->transport ();
+
+ int result = 0;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ TAO_ORB_Core *orb_core = transport->orb_core ();
+
+ while (!ch->is_connect_complete () &&
+ result >= 0)
+ {
+ result = orb_core->run (max_wait_time, 1 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCHANY
+ {
+ result = -1;
+ }
+ ACE_ENDTRY;
+
+ // Set the result.
+ if (ch->is_connect_successful () == 0 && result != -1)
+ result = -1;
+
+ return result;
+}
diff --git a/TAO/tao/Reactive_Connect_Strategy.h b/TAO/tao/Reactive_Connect_Strategy.h
new file mode 100644
index 00000000000..8898c25e08e
--- /dev/null
+++ b/TAO/tao/Reactive_Connect_Strategy.h
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Reactive_Connect_Strategy.h
+ *
+ * $Id$
+ *
+ * @author Balachandran Natarajan <bala@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_REACTIVE_CONNECT_STRATEGY_H
+#define TAO_REACTIVE_CONNECT_STRATEGY_H
+#include "ace/pre.h"
+
+#include "Connect_Strategy.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+class TAO_Connector;
+class ACE_Time_Value;
+class ACE_Synch_Options;
+
+/**
+ * @class TAO_Reactive_Connect_Strategy
+ *
+ * @brief Concrete implementation of a connect strategy that waits on
+ * the reactor during asynch connects
+ *
+ */
+class TAO_Export TAO_Reactive_Connect_Strategy : public TAO_Connect_Strategy
+{
+public:
+ /// Constructor
+ TAO_Reactive_Connect_Strategy (TAO_ORB_Core *orb);
+
+ /// Destructor
+ ~TAO_Reactive_Connect_Strategy (void);
+
+ /*
+ * Concrete implementation for this class. Please see
+ * Connect_Strategy.h for details
+ */
+ virtual void synch_options (ACE_Time_Value *val,
+ ACE_Synch_Options &opt);
+
+ virtual int wait (TAO_Connection_Handler *ch,
+ ACE_Time_Value *val);
+};
+
+
+#endif /*TAO_REACTIVE_CONNECT_STRATEGY_H*/