summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorcleeland <cleeland@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-22 02:44:57 +0000
committercleeland <cleeland@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-22 02:44:57 +0000
commitf675805aee9e9b7204af17c92365a7ed439f3f72 (patch)
treed6880b7fa98f0f5acdc46760cf7f910dedb3115b /TAO
parentb8d6f0c9f924f501e1e7115981e87dc673027bbb (diff)
downloadATCD-f675805aee9e9b7204af17c92365a7ed439f3f72.tar.gz
Created ROA_Factory as the abstract strategy factory, put
ACE_Strategy_Acceptor in place instead of ACE_Acceptor.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog-98c41
-rw-r--r--TAO/IIOP/lib/connect.cpp3
-rw-r--r--TAO/IIOP/lib/connect.hh4
-rw-r--r--TAO/IIOP/lib/params.cpp53
-rw-r--r--TAO/IIOP/lib/params.hh38
-rw-r--r--TAO/IIOP/lib/params.i28
-rw-r--r--TAO/IIOP/lib/roa.cpp17
-rw-r--r--TAO/IIOP/lib/roa.hh14
-rw-r--r--TAO/IIOP/test/clnt.cpp25
9 files changed, 178 insertions, 45 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index b3870ea6665..702705deb71 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,19 +1,42 @@
Mon Apr 21 10:52:42 1997 Chris Cleeland <cleeland@cs.wustl.edu>
- * svrrqst.*: Changed references to BOA_ptr from TOA_ptr.
+ * IIOP/test/clnt.cpp: Moved call to CORBA_ORB_init() prior to the
+ parsing of the command line args. This got switched around during
+ porting to VxWorks.
- * connect.*: ROA_Handler/ROA_Acceptor moved from roa.* into here.
+ * IIOP/lib/roa.cpp: Changed calls using clientAcceptor_to use APIs
+ vended by ACE_Strategy_Acceptor.
- * params.*: ROA_Parameters moved from roa.* into here.
+ * IIOP/lib/roa.hh: Moved default thread flags into ROA_Factory.
- * boa.*: What used to be TOA is now BOA, and lives in here.
+ * IIOP/lib/params.*: Added ROA_Factory, a singleton which is the
+ beginning of an abstract factory dynamically producing runtime
+ strategies based on information found in ROA_Parameters.
- * roa.*: Major restructuring required removal of all classes (see
- other log entries) from here. This file now houses only the ROA
- class.
+ * IIOP/lib/connect.cpp: Added call to ROA_Handler's base class
+ CTOR in initializer list.
- * tcpoa.*,toa.*: Removed because of name changes from TCP_OA->ROA
- and TOA->BOA.
+ * IIOP/lib/connect.hh: Changed ROA_Handler's CTOR so that it can
+ take an optional ACE_Thread_Manager* arg. This makes it
+ compatible with the CTORs for the base class. Also changed base
+ class for ROA_Acceptor to ACE_Strategy_Acceptor.
+
+ * IIOP/lib/svrrqst.*: Changed references to BOA_ptr from TOA_ptr.
+
+ * IIOP/lib/connect.*: ROA_Handler/ROA_Acceptor moved from roa.*
+ into here.
+
+ * IIOP/lib/params.*: ROA_Parameters moved from roa.* into here.
+
+ * IIOP/lib/boa.*: What used to be TOA is now BOA, and lives in
+ here.
+
+ * IIOP/lib/roa.*: Major restructuring required removal of all
+ classes (see other log entries) from here. This file now houses
+ only the ROA class.
+
+ * IIOP/lib/{tcpoa.*,toa.*}: Removed because of name changes from
+ TCP_OA->ROA and TOA->BOA.
Fri Apr 18 08:09:19 1997 Brian Mendel <bmendel@mdc.com>
diff --git a/TAO/IIOP/lib/connect.cpp b/TAO/IIOP/lib/connect.cpp
index 499eefb2624..c7222826496 100644
--- a/TAO/IIOP/lib/connect.cpp
+++ b/TAO/IIOP/lib/connect.cpp
@@ -12,7 +12,8 @@
#include "debug.hh"
-ROA_Handler::ROA_Handler()
+ROA_Handler::ROA_Handler(ACE_Thread_Manager* t)
+ : SUPERCLASS(t)
{
// Grab the singleton...at some later point in time
// we can provide an argumented CTOR to have per-instance
diff --git a/TAO/IIOP/lib/connect.hh b/TAO/IIOP/lib/connect.hh
index 5cac99e8e84..02315504f73 100644
--- a/TAO/IIOP/lib/connect.hh
+++ b/TAO/IIOP/lib/connect.hh
@@ -12,7 +12,7 @@
class ROA_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
{
public:
- ROA_Handler();
+ ROA_Handler(ACE_Thread_Manager* t = ACE_Service_Config::thr_mgr());
virtual int open(void*);
virtual int svc(void);
@@ -28,7 +28,7 @@ private:
ROA_Parameters* params_;
};
-typedef ACE_Acceptor<ROA_Handler, ACE_SOCK_ACCEPTOR> ROA_Acceptor;
+typedef ACE_Strategy_Acceptor<ROA_Handler, ACE_SOCK_ACCEPTOR> ROA_Acceptor;
# if defined(__ACE_INLINE__)
# include "connect.i"
diff --git a/TAO/IIOP/lib/params.cpp b/TAO/IIOP/lib/params.cpp
index 8e0ca93a366..85540e1a8f4 100644
--- a/TAO/IIOP/lib/params.cpp
+++ b/TAO/IIOP/lib/params.cpp
@@ -1,6 +1,8 @@
#include "params.hh"
+#include "connect.hh"
ROA_Parameters* ROA_Parameters::_instance = 0;
+ROA_Factory* ROA_Factory::_instance = 0;
ROA_Parameters::ROA_Parameters()
: using_threads_(0),
@@ -22,6 +24,57 @@ ROA_Parameters::instance()
return _instance;
}
+ROA_Factory*
+ROA_Factory::instance()
+{
+ if (_instance == 0)
+ {
+ _instance = new ROA_Factory;
+ }
+ return _instance;
+}
+
+// Determine the appropriate default thread flags, based on system.
+// When I put the concurrency strategy into the factory, then this will
+// go away b/c the concurrency strategy will do this appropriate
+// for each platform!
+# if defined(linux)
+# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED)
+# elif defined(WIN32)
+# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED|THR_SCOPE_PROCESS)
+# elif defined(sparc)
+# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED|THR_SCOPE_PROCESS)
+# else
+# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED)
+# endif
+
+ROA_Factory::CONCURRENCY_STRATEGY*
+ROA_Factory::concurrency_strategy()
+{
+ ROA_Parameters* p = ROA_Parameters::instance();
+
+
+ if (p->using_threads())
+ {
+ // Set the strategy parameters
+ threaded_strategy_.open(ACE_Service_Config::thr_mgr(), ROA_DEFAULT_THREADFLAGS);
+ concurrency_strategy_ = &threaded_strategy_;
+ }
+ else
+ {
+ concurrency_strategy_ = 0;
+ }
+}
+
+
#if !defined(__ACE_INLINE__)
# include "params.i"
#endif
+
+#if defined(ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
+template class ACE_Thread_Strategy<ROA_Handler>;
+template class ACE_Concurrency_Strategy<ROA_Handler>;
+template class ACE_Creation_Strategy<ROA_Handler>;
+template class ACE_Scheduling_Strategy<ROA_Handler>;
+template class ACE_Accept_Strategy<ROA_Handler, ACE_SOCK_ACCEPTOR>;
+#endif
diff --git a/TAO/IIOP/lib/params.hh b/TAO/IIOP/lib/params.hh
index 0c103783a07..17145076c28 100644
--- a/TAO/IIOP/lib/params.hh
+++ b/TAO/IIOP/lib/params.hh
@@ -18,7 +18,11 @@
# include <corba/boa.hh>
# endif
+# include <ace/SOCK_Acceptor.h>
+# include <ace/Strategies_T.h>
+
class ROA;
+class ROA_Handler;
typedef ROA* ROA_ptr;
class ROA_Parameters
@@ -101,6 +105,40 @@ private:
ROA_ptr oa_; // Pointer to One True Object Adapter
};
+class ROA_Factory
+{
+public:
+ typedef ACE_Creation_Strategy<ROA_Handler> CREATION_STRATEGY;
+ typedef ACE_Accept_Strategy<ROA_Handler, ACE_SOCK_ACCEPTOR> ACCEPT_STRATEGY;
+ typedef ACE_Concurrency_Strategy<ROA_Handler> CONCURRENCY_STRATEGY;
+ typedef ACE_Scheduling_Strategy<ROA_Handler> SCHEDULING_STRATEGY;
+
+ CREATION_STRATEGY* creation_strategy();
+ ACCEPT_STRATEGY* accept_strategy();
+ CONCURRENCY_STRATEGY* concurrency_strategy();
+ SCHEDULING_STRATEGY* scheduling_strategy();
+
+ static ROA_Factory* instance();
+
+protected:
+ ROA_Factory();
+
+private:
+ static ROA_Factory* _instance;
+
+ CONCURRENCY_STRATEGY* concurrency_strategy_;
+ ACE_Thread_Strategy<ROA_Handler> threaded_strategy_;
+
+ // Someday we'll need these!
+#if 0
+ CREATION_STRATEGY* creation_strategy_;
+ ACCEPT_STRATEGY* accept_strategy_;
+ SCHEDULING_STRATEGY* scheduling_strategy_;
+#endif
+
+};
+
+
# if defined(__ACE_INLINE__)
# include "params.i"
# endif
diff --git a/TAO/IIOP/lib/params.i b/TAO/IIOP/lib/params.i
index 0b9f5786afb..b498fcc58ca 100644
--- a/TAO/IIOP/lib/params.i
+++ b/TAO/IIOP/lib/params.i
@@ -69,3 +69,31 @@ ROA_Parameters::thread_flags(u_int f)
{
thread_flags_ = f;
}
+
+ACE_INLINE
+ROA_Factory::ROA_Factory()
+ : concurrency_strategy_(0)
+{
+}
+
+ACE_INLINE
+ROA_Factory::CREATION_STRATEGY*
+ROA_Factory::creation_strategy()
+{
+ return 0;
+}
+
+ACE_INLINE
+ROA_Factory::ACCEPT_STRATEGY*
+ROA_Factory::accept_strategy()
+{
+ return 0;
+}
+
+ACE_INLINE
+ROA_Factory::SCHEDULING_STRATEGY*
+ROA_Factory::scheduling_strategy()
+{
+ return 0;
+}
+
diff --git a/TAO/IIOP/lib/roa.cpp b/TAO/IIOP/lib/roa.cpp
index 08e1791a452..495f377b771 100644
--- a/TAO/IIOP/lib/roa.cpp
+++ b/TAO/IIOP/lib/roa.cpp
@@ -50,7 +50,7 @@ ROA::init (CORBA_ORB_ptr parent,
// Don't know if this is right for what was originally being done. Looks like
// what was set in thread_attr were flags given to pthread_create(). However,
// thread creation (when necessary) is now performed by the Svc_Handler::create().
- (void) ROA_Parameters::instance()->thread_flags(ROA_DEFAULT_THREADFLAGS);
+ //(void) ROA_Parameters::instance()->thread_flags(ROA_DEFAULT_THREADFLAGS);
#if 0
//
@@ -88,23 +88,23 @@ ROA::ROA (CORBA_ORB_ptr owning_orb,
skeleton(0)
{
ROA_Parameters* p = ROA_Parameters::instance();
+ ROA_Factory* f = ROA_Factory::instance();
ACE_ASSERT(p->oa() == 0);
//
// Initialize the endpoint ... or try!
//
- if (clientAcceptor_.open(rendezvous, ACE_Service_Config::reactor()) == -1)
+ if (clientAcceptor_.open(rendezvous,
+ ACE_Service_Config::reactor(),
+ f->creation_strategy(),
+ f->accept_strategy(),
+ f->concurrency_strategy(),
+ f->scheduling_strategy()) == -1)
{
// XXXCJC Need to return an error somehow!! Maybe set do_exit?
}
- else if (ACE_Service_Config::reactor()->register_handler(&clientAcceptor_,
- ACE_Event_Handler::ACCEPT_MASK) == -1)
- {
- // XXXCJC Need to return an error somehow!! Maybe set do_exit?
- }
-
clientAcceptor_.acceptor().get_local_addr(addr);
if (env.exception () != 0)
@@ -762,5 +762,6 @@ request_forwarder (opaque& target_key,
#if defined(ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
// Direct
+template class ACE_Strategy_Acceptor<ROA_Handler, ACE_SOCK_ACCEPTOR>;
// Indirect
#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
diff --git a/TAO/IIOP/lib/roa.hh b/TAO/IIOP/lib/roa.hh
index eba83d83850..862b61a4e8f 100644
--- a/TAO/IIOP/lib/roa.hh
+++ b/TAO/IIOP/lib/roa.hh
@@ -26,20 +26,6 @@ typedef ROA* ROA_ptr;
# include "params.hh"
# include "connect.hh"
-// Determine the appropriate default thread flags, based on system.
-// When I put the concurrency strategy into the factory, then this will
-// go away b/c the concurrency strategy will do this appropriate
-// for each platform!
-# if defined(linux)
-# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED)
-# elif defined(WIN32)
-# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED|THR_SCOPE_PROCESS)
-# elif defined(sparc)
-# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED|THR_SCOPE_PROCESS)
-# else
-# define ROA_DEFAULT_THREADFLAGS (THR_DETACHED)
-# endif
-
extern const IID IID_ROA;
struct Dispatch_Context
diff --git a/TAO/IIOP/test/clnt.cpp b/TAO/IIOP/test/clnt.cpp
index b4a60a43c8c..f10abeb5934 100644
--- a/TAO/IIOP/test/clnt.cpp
+++ b/TAO/IIOP/test/clnt.cpp
@@ -53,18 +53,20 @@ main (int argc, char *argv[])
CORBA_ORB_ptr orb_ptr;
CORBA_Environment env;
CORBA_Object_ptr objref = CORBA_Object::_nil();
- unsigned loop_count = 50;
+ unsigned loop_count = 1;
int exit_later = 0;
#if defined (VXWORKS)
+ // Work around VxWorks' lack of command line
loop_count = 50;
int dummy = 1;
orb_ptr = CORBA_ORB_init (dummy, (char **)0, "internet", env);
-
- //
- // Parse command line and verify parameters.
- //
+ if (env.exception() != 0)
+ {
+ print_exception(env.exception(), "ORB initialization");
+ return 1;
+ }
hostAdd( "mv2604d", "130.38.183.132" );
@@ -72,6 +74,13 @@ main (int argc, char *argv[])
(CORBA_String)"iiop:1.0//mv2604d:1000/key0", env);
#else
+ orb_ptr = CORBA_ORB_init(argc, argv, "internet", env);
+ if (env.exception() != 0)
+ {
+ print_exception(env.exception(), "ORB initialization");
+ return 1;
+ }
+
//
// Parse command line and verify parameters.
//
@@ -116,12 +125,6 @@ main (int argc, char *argv[])
return 1;
}
- orb_ptr = CORBA_ORB_init (argc, argv, "internet", env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "ORB initialisation");
- return 1;
- }
-
#endif
if (CORBA_is_nil (objref) == CORBA_B_TRUE) {