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
13 namespace Portable_Server
15 Non_Servant_Upcall::Non_Servant_Upcall (::TAO_Root_POA
&poa
)
16 : object_adapter_ (poa
.object_adapter ()),
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.
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_
++;
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)
61 this->object_adapter_
.non_servant_upcall_thread_
=
64 // Check if all pending requests are over.
65 if (this->poa_
.waiting_destruction () &&
66 this->poa_
.outstanding_requests () == 0)
70 this->poa_
.complete_destruction_i ();
72 catch (const::CORBA::Exception
&ex
)
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