diff options
Diffstat (limited to 'TAO/tao/Object_Adapter.cpp')
-rw-r--r-- | TAO/tao/Object_Adapter.cpp | 222 |
1 files changed, 23 insertions, 199 deletions
diff --git a/TAO/tao/Object_Adapter.cpp b/TAO/tao/Object_Adapter.cpp index d8daa7dbd11..6f4aa52395e 100644 --- a/TAO/tao/Object_Adapter.cpp +++ b/TAO/tao/Object_Adapter.cpp @@ -100,14 +100,7 @@ TAO_Object_Adapter::TAO_Object_Adapter (const TAO_Server_Strategy_Factory::Activ persistent_poa_name_map_ (0), transient_poa_map_ (0), orb_core_ (orb_core), - enable_locking_ (orb_core_.server_factory ()->enable_poa_locking ()), - thread_lock_ (), - lock_ (TAO_Object_Adapter::create_lock (enable_locking_, - thread_lock_)), - reverse_lock_ (*lock_), - non_servant_upcall_condition_ (thread_lock_), - non_servant_upcall_in_progress_ (0), - non_servant_upcall_thread_ (ACE_OS::NULL_thread) + lock_ (orb_core.server_factory ()->create_poa_lock ()) { TAO_Object_Adapter::set_transient_poa_name_size (creation_parameters); @@ -181,37 +174,9 @@ TAO_Object_Adapter::~TAO_Object_Adapter (void) delete this->hint_strategy_; delete this->persistent_poa_name_map_; delete this->transient_poa_map_; - delete this->lock_; } -/* static */ -ACE_Lock * -TAO_Object_Adapter::create_lock (int enable_locking, - ACE_SYNCH_MUTEX &thread_lock) -{ -#if defined (ACE_HAS_THREADS) - if (enable_locking) - { - ACE_Lock *the_lock = 0; - - ACE_NEW_RETURN (the_lock, - ACE_Lock_Adapter<ACE_SYNCH_MUTEX> (thread_lock), - 0); - - return the_lock; - } -#endif /* ACE_HAS_THREADS */ - - ACE_Lock *the_lock = 0; - - ACE_NEW_RETURN (the_lock, - ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX> (), - 0); - - return the_lock; -} - void TAO_Object_Adapter::dispatch_servant (const TAO_ObjectKey &key, CORBA::ServerRequest &req, @@ -235,21 +200,6 @@ TAO_Object_Adapter::dispatch_servant_i (const TAO_ObjectKey &key, void *context, CORBA_Environment &ACE_TRY_ENV) { - // Check if a non-servant upcall is in progress, and make sure it is - // not this thread which is making the upcall. - while (this->enable_locking_ && - this->non_servant_upcall_in_progress_ && - ! ACE_OS::thr_equal (this->non_servant_upcall_thread_, - ACE_OS::thr_self ())) - { - // If so wait... - int result = this->non_servant_upcall_condition_.wait (); - if (result == -1) - { - ACE_THROW (CORBA::OBJ_ADAPTER ()); - } - } - PortableServer::ObjectId id; TAO_POA *poa = 0; @@ -261,11 +211,11 @@ TAO_Object_Adapter::dispatch_servant_i (const TAO_ObjectKey &key, // Setup for POA Current const char *operation = req.operation (); - TAO_POA_Current_Impl current_context (poa, - key, - 0, - operation, - this->orb_core_); + TAO_POA_Current current_context (poa, + key, + 0, + operation, + this->orb_core_); PortableServer::Servant servant = 0; @@ -283,32 +233,6 @@ TAO_Object_Adapter::dispatch_servant_i (const TAO_ObjectKey &key, current_context.servant (servant); { - // Outstanding_Requests has a magic constructor and destructor. - // We increment <POA::outstanding_requests_> in the constructor. - // We decrement <POA::outstanding_requests_> in the destructor. - // Note that the lock is released after - // <POA::outstanding_requests_> is increased and - // <POA::outstanding_requests_> is decreased after the lock has - // been reacquired. - Outstanding_Requests outstanding_requests (*poa, - *this); - ACE_UNUSED_ARG (outstanding_requests); - - // This class helps us by locking servants in a single threaded - // POA for the duration of the upcall. Single_Threaded_POA_Lock - // has a magic constructor and destructor. We acquire the servant - // lock in the constructor. We release the servant lock in the - // destructor. - Single_Threaded_POA_Lock single_threaded_poa_lock (*poa, - servant); - ACE_UNUSED_ARG (single_threaded_poa_lock); - - // Unlock for the duration of the servant upcall. Reacquire once - // the upcall completes. Even though we are releasing the lock, - // the servant entry in the active object map is reference counted - // and will not get removed/deleted prematurely. - TAO_POA_GUARD (ACE_Lock, monitor, this->reverse_lock (), ACE_TRY_ENV); - ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_DISPATCH_START); // Upcall @@ -347,7 +271,7 @@ TAO_Object_Adapter::locate_poa (const TAO_ObjectKey &key, if (result != 0) { - ACE_THROW (CORBA::OBJ_ADAPTER ()); + ACE_THROW (CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)); } { @@ -363,7 +287,7 @@ TAO_Object_Adapter::locate_poa (const TAO_ObjectKey &key, if (result != 0) { - ACE_THROW (CORBA::OBJECT_NOT_EXIST ()); + ACE_THROW (CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO)); } } @@ -376,16 +300,6 @@ TAO_Object_Adapter::activate_poa (const poa_name &folded_name, #if !defined (TAO_HAS_MINIMUM_CORBA) - // A recursive thread lock without using a recursive thread lock. - // Non_Servant_Upcall has a magic constructor and destructor. We - // unlock the Object_Adapter lock for the duration of the adapter - // activator(s) upcalls; reacquiring once the upcalls complete. - // Even though we are releasing the lock, other threads will not be - // able to make progress since - // <Object_Adapter::non_servant_upcall_in_progress_> has been set. - Non_Servant_Upcall non_servant_upcall (*this); - ACE_UNUSED_ARG (non_servant_upcall); - iteratable_poa_name ipn (folded_name); iteratable_poa_name::iterator iterator = ipn.begin (); iteratable_poa_name::iterator end = ipn.end (); @@ -393,7 +307,7 @@ TAO_Object_Adapter::activate_poa (const poa_name &folded_name, TAO_POA *parent = this->orb_core_.root_poa (); if (parent->name () != *iterator) { - ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO), -1); } else @@ -512,6 +426,9 @@ PortableServer::Servant TAO_Object_Adapter::find_servant_i (const TAO_ObjectKey &key, CORBA::Environment &ACE_TRY_ENV) { + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); + PortableServer::ObjectId id; TAO_POA *poa = 0; @@ -784,97 +701,17 @@ TAO_Object_Adapter::iteratable_poa_name::end (void) const //////////////////////////////////////////////////////////////////////////////// -TAO_Object_Adapter::Non_Servant_Upcall::Non_Servant_Upcall (TAO_Object_Adapter &object_adapter) - : object_adapter_ (object_adapter) -{ - // Mark the fact that a non-servant upcall is in progress. - this->object_adapter_.non_servant_upcall_in_progress_ = 1; - - // Remember which thread is calling the adapter activators. - this->object_adapter_.non_servant_upcall_thread_ = ACE_OS::thr_self (); - - // Release the Object Adapter lock. - this->object_adapter_.lock ().release (); -} - -TAO_Object_Adapter::Non_Servant_Upcall::~Non_Servant_Upcall (void) -{ - // Reacquire the Object Adapter lock. - this->object_adapter_.lock ().acquire (); - - // We are no longer in a non-servant upcall. - this->object_adapter_.non_servant_upcall_in_progress_ = 0; - - // Reset thread id. - this->object_adapter_.non_servant_upcall_thread_ = ACE_OS::NULL_thread; - - // If locking is enabled. - if (this->object_adapter_.enable_locking_) - { - // Wakeup all waiting threads. - this->object_adapter_.non_servant_upcall_condition_.broadcast (); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -TAO_Object_Adapter::Outstanding_Requests::Outstanding_Requests (TAO_POA &poa, - TAO_Object_Adapter &object_adapter) - : poa_ (poa), - object_adapter_ (object_adapter) -{ - // Increase <poa->outstanding_requests_>. - this->poa_.increment_outstanding_requests (); -} - -TAO_Object_Adapter::Outstanding_Requests::~Outstanding_Requests (void) -{ - // Decrease <poa->outstanding_requests_>. - CORBA::ULong outstanding_requests = this->poa_.decrement_outstanding_requests (); - - // If locking is enabled and some thread is waiting in POA::destroy. - if (this->object_adapter_.enable_locking_ && - outstanding_requests == 0 && - this->poa_.destroy_pending_) - { - // Wakeup all waiting threads. - this->poa_.outstanding_requests_condition_.broadcast (); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -TAO_Object_Adapter::Single_Threaded_POA_Lock::Single_Threaded_POA_Lock (TAO_POA &poa, - PortableServer::Servant servant) - : poa_ (poa), - servant_ (servant) -{ -#if !defined (TAO_HAS_MINIMUM_CORBA) - if (this->poa_.policies ().thread () == PortableServer::SINGLE_THREAD_MODEL) - { - this->servant_->_single_threaded_poa_lock ().acquire (); - } -#endif /* TAO_HAS_MINIMUM_CORBA */ -} - -TAO_Object_Adapter::Single_Threaded_POA_Lock::~Single_Threaded_POA_Lock (void) -{ -#if !defined (TAO_HAS_MINIMUM_CORBA) - if (this->poa_.policies ().thread () == PortableServer::SINGLE_THREAD_MODEL) - { - this->servant_->_single_threaded_poa_lock ().release (); - } -#endif /* TAO_HAS_MINIMUM_CORBA */ -} +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -//////////////////////////////////////////////////////////////////////////////// +template class auto_ptr<TAO_Object_Adapter::Hint_Strategy>; +template class auto_ptr<TAO_Object_Adapter::transient_poa_map>; -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy>; +template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map>; // Common typedefs. typedef TAO_Object_Adapter::poa_name key; typedef TAO_POA *value; -typedef ACE_Reverse_Lock<ACE_Lock> REVERSE_LOCK; typedef ACE_Pair<key, value> expanded_value; typedef ACE_Reference_Pair<const key, value> value_type; @@ -882,15 +719,6 @@ typedef ACE_Equal_To<key> compare_keys; typedef TAO_ObjectId_Hash hash_key; typedef ACE_Noop_Key_Generator<key> noop_key_generator; -template class ACE_Reverse_Lock<ACE_Lock>; -template class ACE_Guard<REVERSE_LOCK>; - -template class auto_ptr<TAO_Object_Adapter::Hint_Strategy>; -template class auto_ptr<TAO_Object_Adapter::transient_poa_map>; - -template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy>; -template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map>; - template class ACE_Noop_Key_Generator<key>; // Common @@ -945,10 +773,15 @@ template class ACE_Map_Entry<key, value>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate auto_ptr<TAO_Object_Adapter::Hint_Strategy> +#pragma instantiate auto_ptr<TAO_Object_Adapter::transient_poa_map> + +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map> + // Common typedefs. typedef TAO_Object_Adapter::poa_name key; typedef TAO_POA *value; -typedef ACE_Reverse_Lock<ACE_Lock> REVERSE_LOCK; typedef ACE_Pair<key, value> expanded_value; typedef ACE_Reference_Pair<const key, value> value_type; @@ -956,15 +789,6 @@ typedef ACE_Equal_To<key> compare_keys; typedef TAO_ObjectId_Hash hash_key; typedef ACE_Noop_Key_Generator<key> noop_key_generator; -#pragma instantiate ACE_Reverse_Lock<ACE_Lock> -#pragma instantiate ACE_Guard<REVERSE_LOCK> - -#pragma instantiate auto_ptr<TAO_Object_Adapter::Hint_Strategy> -#pragma instantiate auto_ptr<TAO_Object_Adapter::transient_poa_map> - -#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy> -#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map> - #pragma instantiate ACE_Noop_Key_Generator<key> // Common |