RT_POA_Helper.cpp

Go to the documentation of this file.
00001 // RT_POA_Helper.cpp,v 1.10 2006/03/14 06:14:34 jtc Exp
00002 
00003 #include "orbsvcs/Notify/RT_POA_Helper.h"
00004 #include "tao/RTCORBA/RTCORBA.h"
00005 #include "tao/debug.h"
00006 #include "orbsvcs/NotifyExtC.h"
00007 #include "orbsvcs/Notify/RT_Properties.h"
00008 #include "ace/SString.h"
00009 
00010 ACE_RCSID (Notify,
00011            TAO_Notify_RT_POA_Helper,
00012            "RT_POA_Helper.cpp,v 1.10 2006/03/14 06:14:34 jtc Exp")
00013 
00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 TAO_Notify_RT_POA_Helper::~TAO_Notify_RT_POA_Helper ()
00017 {
00018 }
00019 
00020 void
00021 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL)
00022 {
00023   ACE_CString child_poa_name = this->get_unique_id ();
00024 
00025   this->init (parent_poa, child_poa_name.c_str (), tp_params ACE_ENV_ARG_PARAMETER);
00026 }
00027 
00028 void
00029 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name
00030                                  , const NotifyExt::ThreadPoolParams& tp_params ACE_ENV_ARG_DECL)
00031 {
00032   CORBA::PolicyList policy_list (4);
00033 
00034   this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER);
00035   ACE_CHECK;
00036 
00037   RTCORBA::RTORB_var rt_orb = TAO_Notify_RT_PROPERTIES::instance ()->rt_orb ();
00038 
00039   RTCORBA::PriorityModel priority_model =
00040     tp_params.priority_model == NotifyExt::CLIENT_PROPAGATED ?
00041     RTCORBA::CLIENT_PROPAGATED : RTCORBA::SERVER_DECLARED;
00042 
00043   if (TAO_debug_level > 0)
00044     ACE_DEBUG ((LM_DEBUG, "Priority Model = %d, Server prio = %d\n"
00045                 , tp_params.priority_model, tp_params.server_priority));
00046 
00047   policy_list.length (3);
00048   policy_list[2] =
00049     rt_orb->create_priority_model_policy (priority_model,
00050                                           tp_params.server_priority
00051                                           ACE_ENV_ARG_PARAMETER);
00052   ACE_CHECK;
00053 
00054   if (TAO_debug_level > 0)
00055     ACE_DEBUG ((LM_DEBUG, "Creating threadpool: static threads = %d, def. prio = %d\n"
00056                 , tp_params.static_threads, tp_params.default_priority));
00057 
00058   // Create the thread-pool.
00059   RTCORBA::ThreadpoolId threadpool_id =
00060     rt_orb->create_threadpool (tp_params.stacksize,
00061                                tp_params.static_threads,
00062                                tp_params.dynamic_threads,
00063                                tp_params.default_priority,
00064                                tp_params.allow_request_buffering,
00065                                tp_params.max_buffered_requests,
00066                                tp_params.max_request_buffer_size
00067                                ACE_ENV_ARG_PARAMETER);
00068   ACE_CHECK;
00069 
00070   policy_list.length (4);
00071   policy_list[3] =
00072     rt_orb->create_threadpool_policy (threadpool_id
00073                                       ACE_ENV_ARG_PARAMETER);
00074   ACE_CHECK;
00075 
00076   this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER);
00077 }
00078 
00079 void
00080 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL)
00081 {
00082   ACE_CString child_poa_name = this->get_unique_id ();
00083 
00084   this->init (parent_poa, child_poa_name.c_str (), tpl_params ACE_ENV_ARG_PARAMETER);
00085 }
00086 
00087 void
00088 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name
00089                                  , const NotifyExt::ThreadPoolLanesParams& tpl_params ACE_ENV_ARG_DECL)
00090 {
00091   CORBA::PolicyList policy_list (4);
00092 
00093   this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER);
00094   ACE_CHECK;
00095 
00096   RTCORBA::RTORB_var rt_orb = TAO_Notify_RT_PROPERTIES::instance ()->rt_orb ();
00097 
00098   RTCORBA::PriorityModel priority_model =
00099     tpl_params.priority_model == NotifyExt::CLIENT_PROPAGATED ?
00100     RTCORBA::CLIENT_PROPAGATED : RTCORBA::SERVER_DECLARED;
00101 
00102   policy_list.length (3);
00103   policy_list[2] =
00104     rt_orb->create_priority_model_policy (priority_model,
00105                                           tpl_params.server_priority
00106                                           ACE_ENV_ARG_PARAMETER);
00107   ACE_CHECK;
00108 
00109   // Populate RTCORBA Lanes.
00110   RTCORBA::ThreadpoolLanes lanes (tpl_params.lanes.length ());
00111   lanes.length (tpl_params.lanes.length ());
00112 
00113   for (CORBA::ULong index = 0; index < tpl_params.lanes.length (); ++index)
00114     {
00115       if (TAO_debug_level > 0)
00116             {
00117               ACE_DEBUG ((LM_DEBUG, "Creating threadpool lane %d: priority = %d, static threads = %d\n",
00118                           index, tpl_params.lanes[index].lane_priority, tpl_params.lanes[index].static_threads));
00119             }
00120 
00121       lanes[index].lane_priority = tpl_params.lanes[index].lane_priority;
00122       lanes[index].static_threads = tpl_params.lanes[index].static_threads;
00123       lanes[index].dynamic_threads = tpl_params.lanes[index].dynamic_threads;
00124     }
00125 
00126   // Create the thread-pool.
00127   RTCORBA::ThreadpoolId threadpool_id =
00128     rt_orb->create_threadpool_with_lanes (tpl_params.stacksize,
00129                                           lanes,
00130                                           tpl_params.allow_borrowing,
00131                                           tpl_params.allow_request_buffering,
00132                                           tpl_params.max_buffered_requests,
00133                                           tpl_params.max_request_buffer_size
00134                                           ACE_ENV_ARG_PARAMETER);
00135   ACE_CHECK;
00136 
00137   policy_list.length (4);
00138   policy_list[3] =
00139     rt_orb->create_threadpool_policy (threadpool_id
00140                                       ACE_ENV_ARG_PARAMETER);
00141   ACE_CHECK;
00142 
00143   this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER);
00144 }
00145 
00146 void
00147 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL)
00148 {
00149   CORBA::PolicyList policy_list (1);
00150 
00151   RTCORBA::RTORB_var rt_orb = TAO_Notify_RT_PROPERTIES::instance ()->rt_orb ();
00152 
00153   policy_list.length (1);
00154 
00155   policy_list[0] =
00156     rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
00157                                           0
00158                                           ACE_ENV_ARG_PARAMETER);
00159   ACE_CHECK;
00160 
00161   ACE_CString child_poa_name = this->get_unique_id ();
00162 
00163   this->create_i (parent_poa, child_poa_name.c_str (), policy_list ACE_ENV_ARG_PARAMETER);
00164 }
00165 
00166 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:24:16 2006 for TAO_CosNotification by doxygen 1.3.6