00001 // $Id: POA_Guard.cpp 76898 2007-02-04 18:58:07Z johnnyw $ 00002 00003 #include "tao/PortableServer/POA_Guard.h" 00004 #include "tao/PortableServer/Root_POA.h" 00005 #include "tao/ORB_Constants.h" 00006 00007 ACE_RCSID(PortableServer, 00008 POA_Guard, 00009 "$Id: POA_Guard.cpp 76898 2007-02-04 18:58:07Z johnnyw $") 00010 00011 00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00013 00014 namespace TAO 00015 { 00016 namespace Portable_Server 00017 { 00018 POA_Guard::POA_Guard (::TAO_Root_POA &poa, bool check_for_destruction) 00019 : guard_ (poa.lock ()) 00020 { 00021 if (!this->guard_.locked ()) 00022 throw 00023 CORBA::INTERNAL ( 00024 CORBA::SystemException::_tao_minor_code ( 00025 TAO_GUARD_FAILURE, 00026 0), 00027 CORBA::COMPLETED_NO); 00028 00029 // Check if a non-servant upcall is in progress. If a non-servant 00030 // upcall is in progress, wait for it to complete. Unless of 00031 // course, the thread making the non-servant upcall is this thread. 00032 poa.object_adapter ().wait_for_non_servant_upcalls_to_complete (); 00033 00034 if (check_for_destruction && poa.cleanup_in_progress ()) 00035 throw 00036 CORBA::BAD_INV_ORDER ( 00037 CORBA::SystemException::_tao_minor_code ( 00038 TAO_POA_BEING_DESTROYED, 00039 0), 00040 CORBA::COMPLETED_NO); 00041 } 00042 } 00043 } 00044 00045 TAO_END_VERSIONED_NAMESPACE_DECL