00001
00002
00003 #include "tao/RTPortableServer/RT_Collocation_Resolver.h"
00004
00005 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00006
00007 ACE_RCSID(RTPortableServer,
00008 RT_Collocation_Resolver,
00009 "$Id: RT_Collocation_Resolver.cpp 77155 2007-02-15 15:23:19Z johnnyw $")
00010
00011 #include "tao/ORB_Core.h"
00012 #include "tao/ORB_Core_TSS_Resources.h"
00013 #include "tao/Object.h"
00014 #include "tao/Stub.h"
00015 #include "tao/PortableServer/Servant_Upcall.h"
00016 #include "tao/PortableServer/Root_POA.h"
00017 #include "tao/RTCORBA/Thread_Pool.h"
00018 #include "tao/Profile.h"
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 CORBA::Boolean
00023 TAO_RT_Collocation_Resolver::is_collocated (CORBA::Object_ptr object) const
00024 {
00025
00026
00027 if (!object->_is_collocated ())
00028 return false;
00029
00030
00031 TAO_ORB_Core *orb_core = object->_stubobj ()->servant_orb_var ()->orb_core ();
00032
00033
00034
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
00040 TAO_Thread_Pool *target_thread_pool =
00041 static_cast <TAO_Thread_Pool *> (poa->thread_pool ());
00042
00043
00044
00045 if (target_thread_pool == 0)
00046 return true;
00047
00048
00049 TAO_ORB_Core_TSS_Resources &tss =
00050 *orb_core->get_tss_resources ();
00051
00052
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
00059 if (current_thread_lane)
00060 current_thread_pool =
00061 ¤t_thread_lane->pool ();
00062
00063
00064
00065
00066 if (current_thread_pool != target_thread_pool)
00067 return false;
00068
00069
00070
00071 if (current_thread_pool == 0)
00072 return true;
00073
00074
00075
00076 if (!current_thread_pool->with_lanes ())
00077 return true;
00078
00079
00080
00081
00082 TAO::Portable_Server::Cached_Policies::PriorityModel priority_model =
00083 poa->priority_model ();
00084
00085
00086
00087
00088 if (priority_model == TAO::Portable_Server::Cached_Policies::CLIENT_PROPAGATED)
00089 return true;
00090
00091
00092
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
00102
00103 if (target_priority == current_thread_lane->lane_priority ())
00104 return true;
00105 else
00106 return false;
00107 }
00108
00109 TAO_END_VERSIONED_NAMESPACE_DECL
00110
00111 ACE_STATIC_SVC_DEFINE (TAO_RT_Collocation_Resolver,
00112 ACE_TEXT ("RT_Collocation_Resolver"),
00113 ACE_SVC_OBJ_T,
00114 &ACE_SVC_NAME (TAO_RT_Collocation_Resolver),
00115 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00116 0)
00117 ACE_FACTORY_DEFINE (TAO_RTPortableServer, TAO_RT_Collocation_Resolver)
00118
00119 #endif