Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / PortableServer / Non_Servant_Upcall.cpp
blob58bb91a393611477fa4ca2db88c668d83b19c812
1 #include "tao/PortableServer/Non_Servant_Upcall.h"
2 #include "tao/PortableServer/Object_Adapter.h"
3 #include "tao/PortableServer/Root_POA.h"
5 #if !defined (__ACE_INLINE__)
6 # include "tao/PortableServer/Non_Servant_Upcall.inl"
7 #endif /* __ACE_INLINE__ */
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 namespace TAO
13 namespace Portable_Server
15 Non_Servant_Upcall::Non_Servant_Upcall (::TAO_Root_POA &poa)
16 : object_adapter_ (poa.object_adapter ()),
17 poa_ (poa),
18 previous_ (0)
20 // Check if this is a nested non_servant_upcall.
21 if (this->object_adapter_.non_servant_upcall_nesting_level_ != 0)
23 // Remember previous instance of non_servant_upcall.
24 this->previous_ =
25 this->object_adapter_.non_servant_upcall_in_progress_;
27 // Assert that the thread is the same as the one before.
28 ACE_ASSERT (ACE_OS::thr_equal (
29 this->object_adapter_.non_servant_upcall_thread_,
30 ACE_OS::thr_self ()));
33 // Remember which thread is calling the adapter activators.
34 this->object_adapter_.non_servant_upcall_thread_ = ACE_OS::thr_self ();
36 // Mark the fact that a non-servant upcall is in progress.
37 this->object_adapter_.non_servant_upcall_in_progress_ = this;
39 // Adjust the nesting level.
40 this->object_adapter_.non_servant_upcall_nesting_level_++;
42 // We always release
43 this->object_adapter_.lock ().release ();
46 Non_Servant_Upcall::~Non_Servant_Upcall ()
48 // Reacquire the Object Adapter lock.
49 this->object_adapter_.lock ().acquire ();
51 // Adjust the nesting level.
52 this->object_adapter_.non_servant_upcall_nesting_level_--;
54 // We are done with this nested upcall.
55 this->object_adapter_.non_servant_upcall_in_progress_ = this->previous_;
57 // If we are at the outer nested upcall.
58 if (this->object_adapter_.non_servant_upcall_nesting_level_ == 0)
60 // Reset thread id.
61 this->object_adapter_.non_servant_upcall_thread_ =
62 ACE_OS::NULL_thread;
64 // Check if all pending requests are over.
65 if (this->poa_.waiting_destruction () &&
66 this->poa_.outstanding_requests () == 0)
68 try
70 this->poa_.complete_destruction_i ();
72 catch (const::CORBA::Exception&ex)
74 // Ignore exceptions
75 ex._tao_print_exception ("TAO_POA::complete_destruction_i");
79 // Wakeup all waiting threads.
80 this->object_adapter_.non_servant_upcall_condition_.broadcast ();
86 TAO_END_VERSIONED_NAMESPACE_DECL