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