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 "RT_Collocation_Resolver.cpp,v 1.18 2006/01/27 22:32:08 mxiong Exp")
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
00024 ACE_ENV_ARG_DECL) const
00025 {
00026
00027
00028 if (!object->_is_collocated ())
00029 return false;
00030
00031
00032 TAO_ORB_Core *orb_core =
00033 object->_stubobj ()->servant_orb_var ()->orb_core ();
00034
00035
00036
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
00044 TAO_Thread_Pool *target_thread_pool =
00045 static_cast <TAO_Thread_Pool *> (poa->thread_pool ());
00046
00047
00048
00049 if (target_thread_pool == 0)
00050 return true;
00051
00052
00053 TAO_ORB_Core_TSS_Resources &tss =
00054 *orb_core->get_tss_resources ();
00055
00056
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
00063 if (current_thread_lane)
00064 current_thread_pool =
00065 ¤t_thread_lane->pool ();
00066
00067
00068
00069
00070 if (current_thread_pool != target_thread_pool)
00071 return false;
00072
00073
00074
00075 if (current_thread_pool == 0)
00076 return true;
00077
00078
00079
00080 if (!current_thread_pool->with_lanes ())
00081 return true;
00082
00083
00084
00085
00086 TAO::Portable_Server::Cached_Policies::PriorityModel priority_model =
00087 poa->priority_model ();
00088
00089
00090
00091
00092 if (priority_model == TAO::Portable_Server::Cached_Policies::CLIENT_PROPAGATED)
00093 return true;
00094
00095
00096
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
00107
00108 if (target_priority == current_thread_lane->lane_priority ())
00109 return true;
00110 else
00111 return false;
00112 }
00113
00114 TAO_END_VERSIONED_NAMESPACE_DECL
00115
00116 ACE_STATIC_SVC_DEFINE (TAO_RT_Collocation_Resolver,
00117 ACE_TEXT ("RT_Collocation_Resolver"),
00118 ACE_SVC_OBJ_T,
00119 &ACE_SVC_NAME (TAO_RT_Collocation_Resolver),
00120 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00121 0)
00122 ACE_FACTORY_DEFINE (TAO_RTPortableServer, TAO_RT_Collocation_Resolver)
00123
00124 #endif