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