Non_Servant_Upcall.cpp

Go to the documentation of this file.
00001 // Non_Servant_Upcall.cpp,v 1.5 2006/03/10 07:19:13 jtc Exp
00002 
00003 #include "tao/PortableServer/Non_Servant_Upcall.h"
00004 #include "tao/PortableServer/Object_Adapter.h"
00005 #include "tao/PortableServer/Root_POA.h"
00006 
00007 #if !defined (__ACE_INLINE__)
00008 # include "tao/PortableServer/Non_Servant_Upcall.inl"
00009 #endif /* __ACE_INLINE__ */
00010 
00011 ACE_RCSID (PortableServer,
00012            Non_Servant_Upcall,
00013            "Non_Servant_Upcall.cpp,v 1.5 2006/03/10 07:19:13 jtc Exp")
00014 
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016 
00017 namespace TAO
00018 {
00019   namespace Portable_Server
00020   {
00021     Non_Servant_Upcall::Non_Servant_Upcall (::TAO_Root_POA &poa)
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_ = this->object_adapter_.non_servant_upcall_in_progress_;
00031 
00032           // Assert that the thread is the same as the one before.
00033           ACE_ASSERT (ACE_OS::thr_equal (this->object_adapter_.non_servant_upcall_thread_,
00034                                          ACE_OS::thr_self ()));
00035         }
00036 
00037       // Remember which thread is calling the adapter activators.
00038       this->object_adapter_.non_servant_upcall_thread_ = ACE_OS::thr_self ();
00039 
00040       // Mark the fact that a non-servant upcall is in progress.
00041       this->object_adapter_.non_servant_upcall_in_progress_ = this;
00042 
00043       // Adjust the nesting level.
00044       this->object_adapter_.non_servant_upcall_nesting_level_++;
00045 
00046       // We always release
00047       this->object_adapter_.lock ().release ();
00048     }
00049 
00050     Non_Servant_Upcall::~Non_Servant_Upcall (void)
00051     {
00052       // Reacquire the Object Adapter lock.
00053       this->object_adapter_.lock ().acquire ();
00054 
00055       // Adjust the nesting level.
00056       this->object_adapter_.non_servant_upcall_nesting_level_--;
00057 
00058       // We are done with this nested upcall.
00059       this->object_adapter_.non_servant_upcall_in_progress_ = this->previous_;
00060 
00061       // If we are at the outer nested upcall.
00062       if (this->object_adapter_.non_servant_upcall_nesting_level_ == 0)
00063         {
00064           // Reset thread id.
00065           this->object_adapter_.non_servant_upcall_thread_ =
00066             ACE_OS::NULL_thread;
00067 
00068           // Check if all pending requests are over.
00069           if (this->poa_.waiting_destruction () &&
00070               this->poa_.outstanding_requests () == 0)
00071             {
00072               ACE_TRY_NEW_ENV
00073                 {
00074                   this->poa_.complete_destruction_i (ACE_ENV_SINGLE_ARG_PARAMETER);
00075                   ACE_TRY_CHECK;
00076                 }
00077               ACE_CATCHANY
00078                 {
00079                   // Ignore exceptions
00080                   ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00081                                        "TAO_POA::complete_destruction_i");
00082                 }
00083               ACE_ENDTRY;
00084             }
00085 
00086           // If locking is enabled.
00087           if (this->object_adapter_.enable_locking_)
00088             // Wakeup all waiting threads.
00089             this->object_adapter_.non_servant_upcall_condition_.broadcast ();
00090         }
00091     }
00092   }
00093 }
00094 
00095 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 12:40:39 2006 for TAO_PortableServer by doxygen 1.3.6