RT_POA_Helper.cpp

Go to the documentation of this file.
00001 // $Id: RT_POA_Helper.cpp 76589 2007-01-25 18:04:11Z elliott_c $
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            "$Id: RT_POA_Helper.cpp 76589 2007-01-25 18:04:11Z elliott_c $")
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)
00022 {
00023   ACE_CString child_poa_name = this->get_unique_id ();
00024 
00025   this->init (parent_poa, child_poa_name.c_str (), tp_params);
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)
00031 {
00032   CORBA::PolicyList policy_list (4);
00033 
00034   this->set_policy (parent_poa, policy_list);
00035 
00036   RTCORBA::RTORB_var rt_orb = TAO_Notify_RT_PROPERTIES::instance ()->rt_orb ();
00037 
00038   RTCORBA::PriorityModel priority_model =
00039     tp_params.priority_model == NotifyExt::CLIENT_PROPAGATED ?
00040     RTCORBA::CLIENT_PROPAGATED : RTCORBA::SERVER_DECLARED;
00041 
00042   if (TAO_debug_level > 0)
00043     ACE_DEBUG ((LM_DEBUG, "Priority Model = %d, Server prio = %d\n"
00044                 , tp_params.priority_model, tp_params.server_priority));
00045 
00046   policy_list.length (3);
00047   policy_list[2] =
00048     rt_orb->create_priority_model_policy (priority_model,
00049                                           tp_params.server_priority);
00050 
00051   if (TAO_debug_level > 0)
00052     ACE_DEBUG ((LM_DEBUG, "Creating threadpool: static threads = %d, def. prio = %d\n"
00053                 , tp_params.static_threads, tp_params.default_priority));
00054 
00055   // Create the thread-pool.
00056   RTCORBA::ThreadpoolId threadpool_id =
00057     rt_orb->create_threadpool (tp_params.stacksize,
00058                                tp_params.static_threads,
00059                                tp_params.dynamic_threads,
00060                                tp_params.default_priority,
00061                                tp_params.allow_request_buffering,
00062                                tp_params.max_buffered_requests,
00063                                tp_params.max_request_buffer_size);
00064 
00065   policy_list.length (4);
00066   policy_list[3] =
00067     rt_orb->create_threadpool_policy (threadpool_id);
00068 
00069   this->create_i (parent_poa, poa_name, policy_list);
00070 }
00071 
00072 void
00073 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const NotifyExt::ThreadPoolLanesParams& tpl_params)
00074 {
00075   ACE_CString child_poa_name = this->get_unique_id ();
00076 
00077   this->init (parent_poa, child_poa_name.c_str (), tpl_params);
00078 }
00079 
00080 void
00081 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name
00082                                  , const NotifyExt::ThreadPoolLanesParams& tpl_params)
00083 {
00084   CORBA::PolicyList policy_list (4);
00085 
00086   this->set_policy (parent_poa, policy_list);
00087 
00088   RTCORBA::RTORB_var rt_orb = TAO_Notify_RT_PROPERTIES::instance ()->rt_orb ();
00089 
00090   RTCORBA::PriorityModel priority_model =
00091     tpl_params.priority_model == NotifyExt::CLIENT_PROPAGATED ?
00092     RTCORBA::CLIENT_PROPAGATED : RTCORBA::SERVER_DECLARED;
00093 
00094   policy_list.length (3);
00095   policy_list[2] =
00096     rt_orb->create_priority_model_policy (priority_model,
00097                                           tpl_params.server_priority);
00098 
00099   // Populate RTCORBA Lanes.
00100   RTCORBA::ThreadpoolLanes lanes (tpl_params.lanes.length ());
00101   lanes.length (tpl_params.lanes.length ());
00102 
00103   for (CORBA::ULong index = 0; index < tpl_params.lanes.length (); ++index)
00104     {
00105       if (TAO_debug_level > 0)
00106             {
00107               ACE_DEBUG ((LM_DEBUG, "Creating threadpool lane %d: priority = %d, static threads = %d\n",
00108                           index, tpl_params.lanes[index].lane_priority, tpl_params.lanes[index].static_threads));
00109             }
00110 
00111       lanes[index].lane_priority = tpl_params.lanes[index].lane_priority;
00112       lanes[index].static_threads = tpl_params.lanes[index].static_threads;
00113       lanes[index].dynamic_threads = tpl_params.lanes[index].dynamic_threads;
00114     }
00115 
00116   // Create the thread-pool.
00117   RTCORBA::ThreadpoolId threadpool_id =
00118     rt_orb->create_threadpool_with_lanes (tpl_params.stacksize,
00119                                           lanes,
00120                                           tpl_params.allow_borrowing,
00121                                           tpl_params.allow_request_buffering,
00122                                           tpl_params.max_buffered_requests,
00123                                           tpl_params.max_request_buffer_size);
00124 
00125   policy_list.length (4);
00126   policy_list[3] =
00127     rt_orb->create_threadpool_policy (threadpool_id);
00128 
00129   this->create_i (parent_poa, poa_name, policy_list);
00130 }
00131 
00132 void
00133 TAO_Notify_RT_POA_Helper::init (PortableServer::POA_ptr parent_poa)
00134 {
00135   CORBA::PolicyList policy_list (1);
00136 
00137   RTCORBA::RTORB_var rt_orb = TAO_Notify_RT_PROPERTIES::instance ()->rt_orb ();
00138 
00139   policy_list.length (1);
00140 
00141   policy_list[0] =
00142     rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
00143                                           0);
00144 
00145   ACE_CString child_poa_name = this->get_unique_id ();
00146 
00147   this->create_i (parent_poa, child_poa_name.c_str (), policy_list);
00148 }
00149 
00150 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7