00001 // -*- C++ -*- 00002 // 00003 // POAManager.i,v 1.11 2006/04/26 13:22:58 mesnier_p Exp 00004 00005 #include "tao/Environment.h" 00006 #include "tao/SystemException.h" 00007 00008 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00009 00010 ACE_INLINE ACE_Lock & 00011 TAO_POA_Manager::lock (void) 00012 { 00013 return this->lock_; 00014 } 00015 00016 ACE_INLINE void 00017 TAO_POA_Manager::activate (ACE_ENV_SINGLE_ARG_DECL) 00018 ACE_THROW_SPEC ((CORBA::SystemException, 00019 PortableServer::POAManager::AdapterInactive)) 00020 { 00021 // Lock access to the POAManager for the duration of this transaction 00022 TAO_OBJECT_ADAPTER_GUARD; 00023 00024 this->activate_i (ACE_ENV_SINGLE_ARG_PARAMETER); 00025 } 00026 00027 #if (TAO_HAS_MINIMUM_POA == 0) 00028 00029 ACE_INLINE void 00030 TAO_POA_Manager::hold_requests (CORBA::Boolean wait_for_completion 00031 ACE_ENV_ARG_DECL) 00032 ACE_THROW_SPEC ((CORBA::SystemException, 00033 PortableServer::POAManager::AdapterInactive)) 00034 { 00035 // Lock access to the POAManager for the duration of this transaction 00036 TAO_OBJECT_ADAPTER_GUARD; 00037 00038 this->hold_requests_i (wait_for_completion ACE_ENV_ARG_PARAMETER); 00039 } 00040 00041 ACE_INLINE void 00042 TAO_POA_Manager::discard_requests (CORBA::Boolean wait_for_completion 00043 ACE_ENV_ARG_DECL) 00044 ACE_THROW_SPEC ((CORBA::SystemException, 00045 PortableServer::POAManager::AdapterInactive)) 00046 { 00047 // Lock access to the POAManager for the duration of this transaction 00048 TAO_OBJECT_ADAPTER_GUARD; 00049 00050 this->discard_requests_i (wait_for_completion ACE_ENV_ARG_PARAMETER); 00051 } 00052 00053 ACE_INLINE void 00054 TAO_POA_Manager::deactivate (CORBA::Boolean etherealize_objects, 00055 CORBA::Boolean wait_for_completion 00056 ACE_ENV_ARG_DECL) 00057 ACE_THROW_SPEC ((CORBA::SystemException, 00058 PortableServer::POAManager::AdapterInactive)) 00059 { 00060 // Lock access to the POAManager for the duration of this transaction 00061 TAO_OBJECT_ADAPTER_GUARD; 00062 00063 this->deactivate_i (etherealize_objects, 00064 wait_for_completion 00065 ACE_ENV_ARG_PARAMETER); 00066 } 00067 00068 #endif /* TAO_HAS_MINIMUM_POA == 0 */ 00069 00070 ACE_INLINE PortableServer::POAManager::State 00071 TAO_POA_Manager::get_state_i (void) 00072 ACE_THROW_SPEC ((CORBA::SystemException)) 00073 { 00074 return this->state_; 00075 } 00076 00077 ACE_INLINE PortableServer::POAManager::State 00078 TAO_POA_Manager::get_state (ACE_ENV_SINGLE_ARG_DECL) 00079 ACE_THROW_SPEC ((CORBA::SystemException)) 00080 { 00081 // Lock access to the POAManager for the duration of this transaction 00082 TAO_OBJECT_ADAPTER_GUARD_RETURN (this->state_); 00083 00084 return this->get_state_i (); 00085 } 00086 00087 ACE_INLINE char* 00088 TAO_POA_Manager::generate_manager_id (void) const 00089 { 00090 // The AdapterManagerId must be unique across all Adapter Managers 00091 // (e.g. POAManagers) within a given process. To avoid locking 00092 // overhead, the address of the POAManager object is used as the 00093 // AdapterManagerId. This guarantees that the AdapterManagerId is 00094 // unique. 00095 // 00096 // For 64-bit platforms, only the lower 32 bits are used. Hopefully 00097 // that will be enough to ensure uniqueness. 00098 00099 // This is basically the same trick used in 00100 // TAO_GIOP_Invocation::generate_request_id(). However, no right 00101 // shifting of 64 bit addresses is performed since the 00102 // TAO_POA_Manager object is not large enough to allow that trick. 00103 00104 CORBA::Long id = 0; 00105 00106 // Note that we reinterpret_cast to an "unsigned long" instead of 00107 // CORBA::ULong since we need to first cast to an integer large 00108 // enough to hold an address to avoid compile-time warnings on some 00109 // 64-bit platforms. 00110 00111 if (sizeof (this) == 4) // 32 bit address 00112 id = reinterpret_cast <ptrdiff_t> (this); 00113 00114 else if (sizeof (this) == 8) // 64 bit address -- use lower 32 bits 00115 id = reinterpret_cast <ptrdiff_t> (this) & 0xFFFFFFFFu; 00116 00117 // @@ If we ever hit a platform where neither of the above cases are 00118 // satisfied, we're up the creek! 00119 00120 // else 00121 // // Fallback on an atomically incremented variable specific to the 00122 // // ORB, or perhaps specific to the process. 00123 // id = ...GENERATE_ID_ATOMICALLY...; // Fallback 00124 00125 char* buf = new char [25]; 00126 ACE_OS::sprintf (buf, "POAManager%d", id); 00127 return buf; 00128 } 00129 00130 ACE_INLINE 00131 CORBA::PolicyList& TAO_POA_Manager::get_policies () 00132 { 00133 return this->policies_; 00134 } 00135 00136 00137 TAO_END_VERSIONED_NAMESPACE_DECL