TAO::Portable_Server::Non_Servant_Upcall Class Reference

This class helps us with 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 non-servant (i.e., adapter activator and servant activator) 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. More...

#include <Non_Servant_Upcall.h>

Collaboration diagram for TAO::Portable_Server::Non_Servant_Upcall:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Non_Servant_Upcall (::TAO_Root_POA &poa)
 Constructor.
 ~Non_Servant_Upcall (void)
 Destructor.
::TAO_Root_POApoa (void) const

Protected Attributes

TAO_Object_Adapterobject_adapter_
TAO_Root_POApoa_
Non_Servant_Upcallprevious_

Detailed Description

This class helps us with 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 non-servant (i.e., adapter activator and servant activator) 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.

Definition at line 50 of file Non_Servant_Upcall.h.


Constructor & Destructor Documentation

TAO::Portable_Server::Non_Servant_Upcall::Non_Servant_Upcall ( ::TAO_Root_POA poa  ) 

Constructor.

Definition at line 21 of file Non_Servant_Upcall.cpp.

References ACE_ASSERT, TAO_Object_Adapter::lock(), TAO_Object_Adapter::non_servant_upcall_in_progress_, TAO_Object_Adapter::non_servant_upcall_nesting_level_, TAO_Object_Adapter::non_servant_upcall_thread_, object_adapter_, previous_, ACE_Lock::release(), ACE_OS::thr_equal(), and ACE_OS::thr_self().

00022       : object_adapter_ (poa.object_adapter ()),
00023         poa_ (poa),
00024         previous_ (0)
00025     {
00026       // Check if this is a nested non_servant_upcall.
00027       if (this->object_adapter_.non_servant_upcall_nesting_level_ != 0)
00028         {
00029           // Remember previous instance of non_servant_upcall.
00030           this->previous_ =
00031             this->object_adapter_.non_servant_upcall_in_progress_;
00032 
00033           // Assert that the thread is the same as the one before.
00034           ACE_ASSERT (ACE_OS::thr_equal (
00035                       this->object_adapter_.non_servant_upcall_thread_,
00036                       ACE_OS::thr_self ()));
00037         }
00038 
00039       // Remember which thread is calling the adapter activators.
00040       this->object_adapter_.non_servant_upcall_thread_ = ACE_OS::thr_self ();
00041 
00042       // Mark the fact that a non-servant upcall is in progress.
00043       this->object_adapter_.non_servant_upcall_in_progress_ = this;
00044 
00045       // Adjust the nesting level.
00046       this->object_adapter_.non_servant_upcall_nesting_level_++;
00047 
00048       // We always release
00049       this->object_adapter_.lock ().release ();
00050     }

TAO::Portable_Server::Non_Servant_Upcall::~Non_Servant_Upcall ( void   ) 

Destructor.

Definition at line 52 of file Non_Servant_Upcall.cpp.

References ACE_Lock::acquire(), TAO_Object_Adapter::lock(), TAO_Object_Adapter::non_servant_upcall_condition_, TAO_Object_Adapter::non_servant_upcall_in_progress_, TAO_Object_Adapter::non_servant_upcall_nesting_level_, TAO_Object_Adapter::non_servant_upcall_thread_, ACE_OS::NULL_thread, object_adapter_, TAO_Root_POA::outstanding_requests(), poa_, and previous_.

00053     {
00054       // Reacquire the Object Adapter lock.
00055       this->object_adapter_.lock ().acquire ();
00056 
00057       // Adjust the nesting level.
00058       this->object_adapter_.non_servant_upcall_nesting_level_--;
00059 
00060       // We are done with this nested upcall.
00061       this->object_adapter_.non_servant_upcall_in_progress_ = this->previous_;
00062 
00063       // If we are at the outer nested upcall.
00064       if (this->object_adapter_.non_servant_upcall_nesting_level_ == 0)
00065         {
00066           // Reset thread id.
00067           this->object_adapter_.non_servant_upcall_thread_ =
00068             ACE_OS::NULL_thread;
00069 
00070           // Check if all pending requests are over.
00071           if (this->poa_.waiting_destruction () &&
00072             this->poa_.outstanding_requests () == 0)
00073             {
00074               try
00075                 {
00076                   this->poa_.complete_destruction_i ();
00077                 }
00078               catch (const::CORBA::Exception&ex)
00079                 {
00080                   // Ignore exceptions
00081                   ex._tao_print_exception ("TAO_POA::complete_destruction_i");
00082                 }
00083             }
00084 
00085           // If locking is enabled.
00086           if (this->object_adapter_.enable_locking_)
00087             // Wakeup all waiting threads.
00088             this->object_adapter_.non_servant_upcall_condition_.broadcast ();
00089         }
00090     }


Member Function Documentation

ACE_INLINE::TAO_Root_POA & TAO::Portable_Server::Non_Servant_Upcall::poa ( void   )  const

Definition at line 12 of file Non_Servant_Upcall.inl.

References poa_.

Referenced by TAO_Root_POA::destroy_i().

00013     {
00014       return this->poa_;
00015     }


Member Data Documentation

TAO_Object_Adapter& TAO::Portable_Server::Non_Servant_Upcall::object_adapter_ [protected]

Definition at line 64 of file Non_Servant_Upcall.h.

Referenced by Non_Servant_Upcall(), and ~Non_Servant_Upcall().

TAO_Root_POA& TAO::Portable_Server::Non_Servant_Upcall::poa_ [protected]

Definition at line 65 of file Non_Servant_Upcall.h.

Referenced by poa(), and ~Non_Servant_Upcall().

Non_Servant_Upcall* TAO::Portable_Server::Non_Servant_Upcall::previous_ [protected]

Definition at line 66 of file Non_Servant_Upcall.h.

Referenced by Non_Servant_Upcall(), and ~Non_Servant_Upcall().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:41:45 2010 for TAO_PortableServer by  doxygen 1.4.7