#include <RT_Collocation_Resolver.h>
Inheritance diagram for TAO_RT_Collocation_Resolver:
Public Member Functions | |
virtual CORBA::Boolean | is_collocated (CORBA::Object_ptr object) const |
Is object collocated? |
Definition at line 41 of file RT_Collocation_Resolver.h.
|
Is object collocated? Get the ORB_Core's TSS resources. Implements TAO_Collocation_Resolver. Definition at line 23 of file RT_Collocation_Resolver.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, TAO_ORB_Core::get_tss_resources(), TAO_ORB_Core_TSS_Resources::lane_, and TAO_Thread_Pool.
00025 { 00026 // Make sure that the servant is in the same ORB that created this 00027 // object. 00028 if (!object->_is_collocated ()) 00029 return false; 00030 00031 // Get the orb core. 00032 TAO_ORB_Core *orb_core = 00033 object->_stubobj ()->servant_orb_var ()->orb_core (); 00034 00035 // Lookup the target POA. Note that Object Adapter lock is held 00036 // until <servant_upcall> dies. 00037 TAO::Portable_Server::Servant_Upcall servant_upcall (orb_core); 00038 TAO_Root_POA *poa = 00039 servant_upcall.lookup_POA (object->_stubobj ()->object_key () 00040 ACE_ENV_ARG_PARAMETER); 00041 ACE_CHECK_RETURN (0); 00042 00043 // Get the thread pool associated with this POA. 00044 TAO_Thread_Pool *target_thread_pool = 00045 static_cast <TAO_Thread_Pool *> (poa->thread_pool ()); 00046 00047 // If the target POA does not have a dedicated thread pool, then all 00048 // calls to it are collocated. 00049 if (target_thread_pool == 0) 00050 return true; 00051 00052 /// Get the ORB_Core's TSS resources. 00053 TAO_ORB_Core_TSS_Resources &tss = 00054 *orb_core->get_tss_resources (); 00055 00056 // Get the lane for this thread. 00057 TAO_Thread_Lane *current_thread_lane = 00058 static_cast <TAO_Thread_Lane *> (tss.lane_); 00059 00060 TAO_Thread_Pool *current_thread_pool = 0; 00061 00062 // If we don't have a lane, we don't have a pool. 00063 if (current_thread_lane) 00064 current_thread_pool = 00065 ¤t_thread_lane->pool (); 00066 00067 // If the pools don't match, then the current thread belongs to a 00068 // different pool than POA. Therefore, this object is not 00069 // collocated. 00070 if (current_thread_pool != target_thread_pool) 00071 return false; 00072 00073 // If the current thread and the POA are in the default thread pool, 00074 // then the object is collocated. 00075 if (current_thread_pool == 0) 00076 return true; 00077 00078 // If the current thread and the POA are in a thread pool without 00079 // lanes, then the object is collocated. 00080 if (!current_thread_pool->with_lanes ()) 00081 return true; 00082 00083 // Grab the priority model used by the POA. Note that this cannot 00084 // be NOT_SPECIFIED because NOT_SPECIFIED is not allowed with thread 00085 // pool with lanes. 00086 TAO::Portable_Server::Cached_Policies::PriorityModel priority_model = 00087 poa->priority_model (); 00088 00089 // If the policy is CLIENT_PROPAGATED, then we are collocated 00090 // because the current thread is of the correct priority :-) and 00091 // we'll simple use the current thread to run the upcall. 00092 if (priority_model == TAO::Portable_Server::Cached_Policies::CLIENT_PROPAGATED) 00093 return true; 00094 00095 // Find the target servant priority. We are really not interested in the 00096 // servant itself but in the priority that this servant will run at. 00097 CORBA::Short target_priority; 00098 00099 if (-1 == poa->find_servant_priority (servant_upcall.system_id_, 00100 target_priority 00101 ACE_ENV_ARG_PARAMETER)) 00102 { 00103 return false; 00104 }; 00105 00106 // If it matches the current thread's priority, then we are 00107 // collocated. Otherwise we are not. 00108 if (target_priority == current_thread_lane->lane_priority ()) 00109 return true; 00110 else 00111 return false; 00112 } |