summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-26 23:41:28 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-26 23:41:28 +0000
commit577f4a034ba498e53d21fcccba37bcd92bd10b66 (patch)
tree5b97a9c7672a1a3424d3f8061dbcf9bd968d22d2 /TAO
parent72189f1cb441a64ceabba4e9709f0da38023a6a6 (diff)
downloadATCD-577f4a034ba498e53d21fcccba37bcd92bd10b66.tar.gz
ChangeLogTag:Tue May 26 18:39:11 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog-98c16
-rw-r--r--TAO/tao/ORB.cpp36
-rw-r--r--TAO/tao/ORB.h3
-rw-r--r--TAO/tao/Object.h3
-rw-r--r--TAO/tao/Object.i12
-rw-r--r--TAO/tao/Server_Strategy_Factory.cpp6
-rw-r--r--TAO/tao/Server_Strategy_Factory.h3
-rw-r--r--TAO/tao/default_server.cpp31
-rw-r--r--TAO/tao/default_server.h12
9 files changed, 104 insertions, 18 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index 1a164611884..72abda5abec 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,19 @@
+Tue May 26 18:39:11 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
+
+ * tao/ORB.h:
+ * tao/ORB.cpp:
+ * tao/Server_Strategy_Factory.h:
+ * tao/Server_Strategy_Factory.cpp:
+ * tao/default_server.h:
+ * tao/default_server.cpp:
+ Added options to control the kind of locking in the ORB event
+ loop (i.e. ORB::run), by default it acquires no locks.
+
+ * tao/Object.h:
+ * tao/Object.i:
+ All the objects in the ORB that are reference counted do *not*
+ have locks to protect the count.
+
Tue May 26 18:15:40 1998 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
* orbsvcs/orbsvcs/Naming/CosNaming_i: Changed the implementation
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 480b34acc68..fabcaadf883 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -96,6 +96,12 @@ CORBA_ORB::~CORBA_ORB (void)
// free up all the ORB owned TypeCodes
TAO_TypeCodes::fini ();
}
+
+ if (this->shutdown_lock_ != 0)
+ {
+ delete this->shutdown_lock_;
+ this->shutdown_lock_ = 0;
+ }
}
// Set up listening endpoints.
@@ -131,11 +137,18 @@ CORBA_ORB::open (void)
}
void
-CORBA_ORB::shutdown (CORBA::Boolean wait_for_completion)
+CORBA_ORB::shutdown (CORBA::Boolean /* wait_for_completion */)
{
- ACE_UNUSED_ARG (wait_for_completion);
-
- this->should_shutdown_ = CORBA::B_TRUE;
+ // NOTE: we play some games with this monitor to release the lock
+ // while blocked on I/O.
+ if (this->shutdown_lock_ != 0)
+ {
+ ACE_GUARD (ACE_Lock, monitor, *this->shutdown_lock_);
+ this->should_shutdown_ = 1;
+ }
+ else
+ this->should_shutdown_ = 1;
+
TAO_ORB_Core_instance ()->reactor ()->wakeup_all_threads ();
return;
}
@@ -194,6 +207,10 @@ CORBA_ORB::perform_work (ACE_Time_Value *tv)
int
CORBA_ORB::run (ACE_Time_Value *tv)
{
+ if (this->shutdown_lock_ == 0)
+ this->shutdown_lock_ =
+ TAO_ORB_Core_instance ()->server_factory ()->create_event_loop_lock ();
+
ACE_Reactor *r = TAO_ORB_Core_instance ()->reactor ();
// Set the owning thread of the Reactor to the one which we're
@@ -210,8 +227,16 @@ CORBA_ORB::run (ACE_Time_Value *tv)
// Loop "forever" handling client requests.
const int max_iterations = 100;
int counter = 0;
+
+ // NOTE: we play some games with this monitor to release the lock
+ // while blocked on I/O.
+ ACE_GUARD_RETURN (ACE_Lock, monitor, *this->shutdown_lock_, -1);
+
while (this->should_shutdown_ == 0)
{
+ if (monitor.release () == -1)
+ return -1;
+
counter++;
if (counter == max_iterations)
{
@@ -235,6 +260,9 @@ CORBA_ORB::run (ACE_Time_Value *tv)
break;
/* NOTREACHED */
}
+
+ if (monitor.acquire () == -1)
+ return -1;
}
/* NOTREACHED */
return 0;
diff --git a/TAO/tao/ORB.h b/TAO/tao/ORB.h
index 2fb1378339f..de769815085 100644
--- a/TAO/tao/ORB.h
+++ b/TAO/tao/ORB.h
@@ -911,7 +911,8 @@ private:
ACE_Atomic_Op<ACE_SYNCH_MUTEX, u_int> open_called_;
// Flag which denotes that the open method was called.
- ACE_Atomic_Op<ACE_SYNCH_MUTEX, u_int> should_shutdown_;
+ ACE_Lock* shutdown_lock_;
+ int should_shutdown_;
// Flag which denotes that the ORB should shut down and <run> should
// return.
diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h
index 6f35b1c971b..4c041157cbf 100644
--- a/TAO/tao/Object.h
+++ b/TAO/tao/Object.h
@@ -144,9 +144,6 @@ private:
// It's changed to a STUB_Object to make the relationship of the
// target more explicit and sensible.
- ACE_SYNCH_MUTEX IUnknown_lock_;
- // Mutex to protect reference counting stuff.
-
u_int refcount_;
// Number of outstanding references to this object.
diff --git a/TAO/tao/Object.i b/TAO/tao/Object.i
index 73ecbc00f99..54f0541ef5c 100644
--- a/TAO/tao/Object.i
+++ b/TAO/tao/Object.i
@@ -5,22 +5,14 @@
ACE_INLINE ULONG
CORBA_Object::AddRef (void)
{
- ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->IUnknown_lock_, 0));
-
return ++this->refcount_;
}
ACE_INLINE ULONG
CORBA_Object::Release (void)
{
- {
- ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->IUnknown_lock_, 0));
-
- ACE_ASSERT (this != 0);
-
- if (--this->refcount_ != 0)
- return this->refcount_;
- }
+ if (--this->refcount_ != 0)
+ return this->refcount_;
delete this;
return 0;
}
diff --git a/TAO/tao/Server_Strategy_Factory.cpp b/TAO/tao/Server_Strategy_Factory.cpp
index 4e7a58ed3a0..5dd110604c9 100644
--- a/TAO/tao/Server_Strategy_Factory.cpp
+++ b/TAO/tao/Server_Strategy_Factory.cpp
@@ -64,6 +64,12 @@ TAO_Server_Strategy_Factory::create_servant_lock (void)
return 0;
}
+ACE_Lock *
+TAO_Server_Strategy_Factory::create_event_loop_lock (void)
+{
+ return 0;
+}
+
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Creation_Strategy<TAO_Server_Connection_Handler>;
template class ACE_Acceptor<TAO_Server_Connection_Handler, TAO_SOCK_ACCEPTOR>;
diff --git a/TAO/tao/Server_Strategy_Factory.h b/TAO/tao/Server_Strategy_Factory.h
index 4da0546c5b3..2e5f1835714 100644
--- a/TAO/tao/Server_Strategy_Factory.h
+++ b/TAO/tao/Server_Strategy_Factory.h
@@ -73,6 +73,9 @@ public:
virtual ACE_Lock *create_servant_lock (void);
// Return a new lock for use in locking the servant.
+
+ virtual ACE_Lock *create_event_loop_lock (void);
+ // Return a new lock for use in the ORB event loop.
};
#endif /* TAO_SERVER_STRATEGY_FACTORY_H */
diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp
index 3c6e493694a..308efbec58c 100644
--- a/TAO/tao/default_server.cpp
+++ b/TAO/tao/default_server.cpp
@@ -13,6 +13,7 @@ TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory (void)
object_lookup_strategy_ (TAO_DYNAMIC_HASH),
poa_lock_type_ (TAO_THREAD_LOCK),
poa_mgr_lock_type_ (TAO_THREAD_LOCK),
+ event_loop_lock_type_ (TAO_NULL_LOCK),
concurrency_strategy_ (0)
{
}
@@ -101,6 +102,23 @@ TAO_Default_Server_Strategy_Factory::create_servant_lock (void)
return the_lock;
}
+ACE_Lock *
+TAO_Default_Server_Strategy_Factory::create_event_loop_lock (void)
+{
+ ACE_Lock *the_lock = 0;
+
+ if (this->event_loop_lock_type_ == TAO_NULL_LOCK)
+ ACE_NEW_RETURN (the_lock,
+ ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX> (),
+ 0);
+ else
+ ACE_NEW_RETURN (the_lock,
+ ACE_Lock_Adapter<ACE_SYNCH_RECURSIVE_MUTEX> (),
+ 0);
+
+ return the_lock;
+}
+
TAO_Object_Table_Impl *
TAO_Default_Server_Strategy_Factory::create_object_table (void)
{
@@ -262,6 +280,19 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
this->poa_mgr_lock_type_ = TAO_NULL_LOCK;
}
}
+ else if (ACE_OS::strcmp (argv[curarg], "-ORBeventlock") == 0)
+ {
+ curarg++;
+ if (curarg < argc)
+ {
+ char *name = argv[curarg];
+
+ if (ACE_OS::strcasecmp (name, "thread") == 0)
+ this->poa_mgr_lock_type_ = TAO_THREAD_LOCK;
+ else if (ACE_OS::strcasecmp (name, "null") == 0)
+ this->poa_mgr_lock_type_ = TAO_NULL_LOCK;
+ }
+ }
else if (ACE_OS::strcmp (argv[curarg], "-ORBthreadflags") == 0)
{
curarg++;
diff --git a/TAO/tao/default_server.h b/TAO/tao/default_server.h
index 4f868b5b06c..7bdb4a5ae3c 100644
--- a/TAO/tao/default_server.h
+++ b/TAO/tao/default_server.h
@@ -66,6 +66,13 @@ public:
// else if ORB_init count > 1 return
// ACE_Thread_Mutex.
+ virtual ACE_Lock *create_event_loop_lock (void);
+ // Creates and returns a lock for the event loop.
+ // If the ORB is single threaded or some form of ORB-per-thread then
+ // it is more efficient to use a Null_Mutex for the variables
+ // controlling the event loop (termination). Otherwise a
+ // Recursive_Thread_Mutex or Thread_Mutex may be required.
+
// = Service Configurator hooks.
virtual int init (int argc, char *argv[]);
// Initialize the ORB when it's linked dynamically.
@@ -82,6 +89,8 @@ public:
// where <{which}> is one of <thread> or <null> (default <thread>)
// <-ORBpoamgrlock> <{which}>
// where <{which}> is one of <thread> or <null> (default <thread>)
+ // <-ORBeventlock> <{which}>
+ // where <{which}> is one of <thread> or <null> (default <null>)
private:
void tokenize (char *flag_string);
@@ -107,6 +116,9 @@ private:
Lock_Type poa_mgr_lock_type_;
// The type of lock to be returned by <create_poa_mgr_lock()>.
+ Lock_Type event_loop_lock_type_;
+ // The type of lock to be returned by <create_event_loop_lock()>.
+
// = Strategies Used.
TAO_Reactive_Strategy<TAO_Server_Connection_Handler> reactive_strategy_;
// A strategy for passively establishing connections which utilizes