TAO_RT_ORBInitializer Class Reference

RTCORBA ORB initializer. More...

#include <RT_ORBInitializer.h>

Inheritance diagram for TAO_RT_ORBInitializer:

Inheritance graph
[legend]
Collaboration diagram for TAO_RT_ORBInitializer:

Collaboration graph
[legend]
List of all members.

Public Types

 TAO_PRIORITY_MAPPING_CONTINUOUS
 TAO_PRIORITY_MAPPING_LINEAR
 TAO_PRIORITY_MAPPING_DIRECT
 TAO_NETWORK_PRIORITY_MAPPING_LINEAR
 TAO_RTCORBA_DT_INFINITIVE
 TAO_RTCORBA_DT_IDLE
 TAO_RTCORBA_DT_FIXED
enum  { TAO_PRIORITY_MAPPING_CONTINUOUS, TAO_PRIORITY_MAPPING_LINEAR, TAO_PRIORITY_MAPPING_DIRECT }
 Priority mapping types. More...
enum  { TAO_NETWORK_PRIORITY_MAPPING_LINEAR }
enum  TAO_RTCORBA_DT_LifeSpan { TAO_RTCORBA_DT_INFINITIVE, TAO_RTCORBA_DT_IDLE, TAO_RTCORBA_DT_FIXED }

Public Member Functions

 TAO_RT_ORBInitializer (int priority_mapping_type, int network_priority_mapping_type, int ace_sched_policy, long sched_policy, long scope_policy, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time)
virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info)
virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info)

Private Member Functions

void register_policy_factories (PortableInterceptor::ORBInitInfo_ptr info)
 Register RTCORBA policy factories.

Private Attributes

PortableInterceptor::PolicyFactory_var policy_factory_
 Instance of the RTCorba policy factory.
int const priority_mapping_type_
 Priority mapping type.
int const network_priority_mapping_type_
 Network Priority mapping type.
int const ace_sched_policy_
 Scheduling policy.
long const sched_policy_
 Scheduling policy flag.
long const scope_policy_
 Scheduling scope flag.
TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan_
 Dynamic thread lifespan policy.
ACE_Time_Value const dynamic_thread_time_
 Dynamic thread time.

Detailed Description

RTCORBA ORB initializer.

Definition at line 42 of file RT_ORBInitializer.h.


Member Enumeration Documentation

anonymous enum

Priority mapping types.

Enumerator:
TAO_PRIORITY_MAPPING_CONTINUOUS 
TAO_PRIORITY_MAPPING_LINEAR 
TAO_PRIORITY_MAPPING_DIRECT 

Definition at line 48 of file RT_ORBInitializer.h.

anonymous enum

Enumerator:
TAO_NETWORK_PRIORITY_MAPPING_LINEAR 

Definition at line 55 of file RT_ORBInitializer.h.

00056     {
00057       TAO_NETWORK_PRIORITY_MAPPING_LINEAR
00058     };

enum TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan

Enumerator:
TAO_RTCORBA_DT_INFINITIVE 
TAO_RTCORBA_DT_IDLE 
TAO_RTCORBA_DT_FIXED 

Definition at line 69 of file RT_ORBInitializer.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_RT_ORBInitializer::TAO_RT_ORBInitializer ( int  priority_mapping_type,
int  network_priority_mapping_type,
int  ace_sched_policy,
long  sched_policy,
long  scope_policy,
TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan  lifespan,
ACE_Time_Value const &  dynamic_thread_time 
)

Definition at line 49 of file RT_ORBInitializer.cpp.

00056   : priority_mapping_type_ (priority_mapping_type),
00057     network_priority_mapping_type_ (network_priority_mapping_type),
00058     ace_sched_policy_ (ace_sched_policy),
00059     sched_policy_ (sched_policy),
00060     scope_policy_ (scope_policy),
00061     lifespan_ (lifespan),
00062     dynamic_thread_time_ (dynamic_thread_time)
00063 {
00064 }


Member Function Documentation

void TAO_RT_ORBInitializer::post_init ( PortableInterceptor::ORBInitInfo_ptr  info  )  [virtual]

Definition at line 210 of file RT_ORBInitializer.cpp.

References register_policy_factories().

00211 {
00212   this->register_policy_factories (info);
00213 }

void TAO_RT_ORBInitializer::pre_init ( PortableInterceptor::ORBInitInfo_ptr  info  )  [virtual]

Definition at line 67 of file RT_ORBInitializer.cpp.

References CORBA::Object::_nil(), CORBA::SystemException::_tao_minor_code(), ACE_ERROR, ACE_NEW, ACE_NEW_THROW_EX, ACE_TEXT_ALWAYS_CHAR, CORBA::COMPLETED_NO, dynamic_thread_time_, CORBA::is_nil(), lifespan_, LM_ERROR, CORBA::Object::orb_core(), TAO_ORB_Core::orb_params(), ACE_Service_Config::process_directive(), TAO_ORB_Parameters::scope_policy(), TAO_debug_level, TAO_NETWORK_PRIORITY_MAPPING_LINEAR, TAO_OBJID_RTCURRENT, TAO_OBJID_RTORB, TAO_PRIORITY_MAPPING_CONTINUOUS, TAO_PRIORITY_MAPPING_DIRECT, TAO_PRIORITY_MAPPING_LINEAR, and TAO::VMCID.

00068 {
00069   //
00070   // Register all of the RT related services.
00071   //
00072 
00073   // Narrow to a TAO_ORBInitInfo object to get access to the
00074   // orb_core() TAO extension.
00075   TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
00076 
00077   if (CORBA::is_nil (tao_info.in ()))
00078     {
00079       if (TAO_debug_level > 0)
00080         ACE_ERROR ((LM_ERROR,
00081                     "(%P|%t) TAO_RT_ORBInitializer::pre_init:\n"
00082                     "(%P|%t)    Unable to narrow "
00083                     "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00084                     "(%P|%t)   \"TAO_ORBInitInfo *.\"\n"));
00085 
00086       throw ::CORBA::INTERNAL ();
00087     }
00088 
00089   // Set the name of the Protocol_Hooks to be RT_Protocols_Hooks.
00090   tao_info->orb_core ()->orb_params ()->protocols_hooks_name ("RT_Protocols_Hooks");
00091   ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Protocols_Hooks);
00092 
00093   // Set the name of the stub factory to be RT_Stub_Factory.
00094   tao_info->orb_core ()->orb_params ()->stub_factory_name ("RT_Stub_Factory");
00095   ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Stub_Factory);
00096 
00097   // Set the name of the stub factory to be RT_Stub_Factory.
00098   tao_info->orb_core ()->orb_params ()->endpoint_selector_factory_name ("RT_Endpoint_Selector_Factory");
00099   ACE_Service_Config::process_directive (ace_svc_desc_RT_Endpoint_Selector_Factory);
00100 
00101   // Set the name of the thread lane resources manager to be RT_Thread_Lane_Resources_Manager.
00102   tao_info->orb_core ()->orb_params ()->thread_lane_resources_manager_factory_name ("RT_Thread_Lane_Resources_Manager_Factory");
00103   ACE_Service_Config::process_directive (ace_svc_desc_TAO_RT_Thread_Lane_Resources_Manager_Factory);
00104 
00105   // If the application resolves the root POA, make sure we load the RT POA.
00106   tao_info->orb_core ()->orb_params ()->poa_factory_name (rt_poa_factory_name);
00107   tao_info->orb_core ()->orb_params ()->poa_factory_directive (ACE_TEXT_ALWAYS_CHAR (rt_poa_factory_directive));
00108 
00109   // Create the initial priority mapping instance.
00110   TAO_Priority_Mapping *pm = 0;
00111   switch (this->priority_mapping_type_)
00112     {
00113     case TAO_PRIORITY_MAPPING_CONTINUOUS:
00114       ACE_NEW (pm,
00115                TAO_Continuous_Priority_Mapping (this->ace_sched_policy_));
00116       break;
00117     case TAO_PRIORITY_MAPPING_LINEAR:
00118       ACE_NEW (pm,
00119                TAO_Linear_Priority_Mapping (this->ace_sched_policy_));
00120       break;
00121     default:
00122     case TAO_PRIORITY_MAPPING_DIRECT:
00123       ACE_NEW (pm,
00124                TAO_Direct_Priority_Mapping (this->ace_sched_policy_));
00125       break;
00126     }
00127 
00128   // Set the Priority_Mapping_Manager
00129   TAO_Priority_Mapping_Manager *manager = 0;
00130 
00131   ACE_NEW_THROW_EX (manager,
00132                     TAO_Priority_Mapping_Manager (pm),
00133                     CORBA::NO_MEMORY (
00134                       CORBA::SystemException::_tao_minor_code (
00135                         TAO::VMCID,
00136                         ENOMEM),
00137                       CORBA::COMPLETED_NO));
00138 
00139   TAO_Priority_Mapping_Manager_var safe_manager = manager;
00140 
00141   info->register_initial_reference ("PriorityMappingManager", manager);
00142 
00143   // Create the initial priority mapping instance.
00144   TAO_Network_Priority_Mapping *npm = 0;
00145   switch (this->network_priority_mapping_type_)
00146     {
00147     default:
00148     case TAO_NETWORK_PRIORITY_MAPPING_LINEAR:
00149       ACE_NEW (npm,
00150                TAO_Linear_Network_Priority_Mapping (this->ace_sched_policy_));
00151       break;
00152     }
00153 
00154   // Set the Priority_Mapping_Manager
00155   TAO_Network_Priority_Mapping_Manager * network_manager = 0;
00156 
00157   // @@ There is a potential memory leak here.  If the new() below
00158   //    throws an exception, the memory for the network priority
00159   //    mapping allocated above will be leaked.  Use an auto_ptr<> or
00160   //    the appropriate memory management tool.
00161 
00162   ACE_NEW_THROW_EX (network_manager,
00163                     TAO_Network_Priority_Mapping_Manager (npm),
00164                     CORBA::NO_MEMORY (
00165                       CORBA::SystemException::_tao_minor_code (
00166                         TAO::VMCID,
00167                         ENOMEM),
00168                       CORBA::COMPLETED_NO));
00169 
00170   TAO_Network_Priority_Mapping_Manager_var safe_network_manager =
00171     network_manager;
00172 
00173   info->register_initial_reference ("NetworkPriorityMappingManager",
00174                                     network_manager);
00175 
00176   // Create the RT_ORB.
00177   CORBA::Object_ptr rt_orb = CORBA::Object::_nil ();
00178   ACE_NEW_THROW_EX (rt_orb,
00179                     TAO_RT_ORB (tao_info->orb_core (),
00180                     lifespan_,
00181                     dynamic_thread_time_),
00182                     CORBA::NO_MEMORY (
00183                       CORBA::SystemException::_tao_minor_code (
00184                         TAO::VMCID,
00185                         ENOMEM),
00186                       CORBA::COMPLETED_NO));
00187   CORBA::Object_var safe_rt_orb = rt_orb;
00188 
00189   info->register_initial_reference (TAO_OBJID_RTORB, rt_orb);
00190 
00191   // Create the RT_Current.
00192   CORBA::Object_ptr current = CORBA::Object::_nil ();
00193   ACE_NEW_THROW_EX (current,
00194                     TAO_RT_Current (tao_info->orb_core ()),
00195                     CORBA::NO_MEMORY (
00196                       CORBA::SystemException::_tao_minor_code (
00197                         TAO::VMCID,
00198                         ENOMEM),
00199                       CORBA::COMPLETED_NO));
00200   CORBA::Object_var safe_rt_current = current;
00201 
00202   info->register_initial_reference (TAO_OBJID_RTCURRENT, current);
00203 
00204   tao_info->orb_core ()->orb_params ()->scope_policy (this->scope_policy_);
00205   tao_info->orb_core ()->orb_params ()->sched_policy (this->sched_policy_);
00206   tao_info->orb_core ()->orb_params ()->ace_sched_policy (this->ace_sched_policy_);
00207 }

void TAO_RT_ORBInitializer::register_policy_factories ( PortableInterceptor::ORBInitInfo_ptr  info  )  [private]

Register RTCORBA policy factories.

Definition at line 216 of file RT_ORBInitializer.cpp.

References CORBA::SystemException::_tao_minor_code(), ACE_NEW_THROW_EX, CORBA::COMPLETED_NO, CORBA::is_nil(), CORBA::OMGVMCID, policy_factory_, and TAO::VMCID.

Referenced by post_init().

00218 {
00219   // The RTCorba policy factory is stateless and reentrant, so share a
00220   // single instance between all ORBs.
00221   if (CORBA::is_nil (this->policy_factory_.in ()))
00222     {
00223       PortableInterceptor::PolicyFactory_ptr policy_factory;
00224       ACE_NEW_THROW_EX (policy_factory,
00225                         TAO_RT_PolicyFactory,
00226                           CORBA::NO_MEMORY (
00227                             CORBA::SystemException::_tao_minor_code (
00228                               TAO::VMCID,
00229                               ENOMEM),
00230                             CORBA::COMPLETED_NO));
00231 
00232       this->policy_factory_ = policy_factory;
00233     }
00234 
00235   // Bind the same policy factory to all RTCORBA related policy
00236   // types since a single policy factory is used to create each of
00237   // the different types of RTCORBA policies.
00238   static CORBA::PolicyType const type[] = {
00239     RTCORBA::PRIORITY_MODEL_POLICY_TYPE,
00240     RTCORBA::THREADPOOL_POLICY_TYPE,
00241     RTCORBA::SERVER_PROTOCOL_POLICY_TYPE,
00242     RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE,
00243     RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE,
00244     RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE
00245   };
00246 
00247   const CORBA::PolicyType *end =
00248     type + sizeof (type) / sizeof (type[0]);
00249 
00250   for (CORBA::PolicyType const * i = type;
00251        i != end;
00252        ++i)
00253     {
00254       try
00255         {
00256           info->register_policy_factory (*i, this->policy_factory_.in ());
00257         }
00258       catch (const ::CORBA::BAD_INV_ORDER& ex)
00259         {
00260           if (ex.minor () == (CORBA::OMGVMCID | 16))
00261             {
00262               // The factory is already there, it happens because the
00263               // magic initializer in PortableServer.cpp registers
00264               // with the ORB multiple times.  This is an indication
00265               // that we should do no more work in this
00266               // ORBInitializer.
00267               return;
00268             }
00269           throw;
00270         }
00271     }
00272 }


Member Data Documentation

int const TAO_RT_ORBInitializer::ace_sched_policy_ [private]

Scheduling policy.

Scheduling policy specified by the user through the -ORBSchedPolicy option. This value is typically used by functions like ACE_OS::thr_setprio() and ACE_Sched_Params::priority_min(). Legal values are ACE_SCHED_RR, ACE_SCHED_FIFO, and ACE_SCHED_OTHER.

Definition at line 115 of file RT_ORBInitializer.h.

ACE_Time_Value const TAO_RT_ORBInitializer::dynamic_thread_time_ [private]

Dynamic thread time.

When using thread pool a certain number of dynamic threads can be created. By default these threads are created when needed but never end. Optionally a time can be specified

Definition at line 144 of file RT_ORBInitializer.h.

Referenced by pre_init().

TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan TAO_RT_ORBInitializer::lifespan_ [private]

Dynamic thread lifespan policy.

Definition at line 136 of file RT_ORBInitializer.h.

Referenced by pre_init().

int const TAO_RT_ORBInitializer::network_priority_mapping_type_ [private]

Network Priority mapping type.

Definition at line 105 of file RT_ORBInitializer.h.

PortableInterceptor::PolicyFactory_var TAO_RT_ORBInitializer::policy_factory_ [private]

Instance of the RTCorba policy factory.

The RTCorba policy factory is stateless and reentrant, so share a single instance between all ORBs.

Definition at line 99 of file RT_ORBInitializer.h.

Referenced by register_policy_factories().

int const TAO_RT_ORBInitializer::priority_mapping_type_ [private]

Priority mapping type.

Definition at line 102 of file RT_ORBInitializer.h.

long const TAO_RT_ORBInitializer::sched_policy_ [private]

Scheduling policy flag.

Scheduling policy specified by the user through the -ORBSchedPolicy option. This value is typically used by ACE thread creation functions. Legal values are THR_SCHED_RR, THR_SCHED_FIFO, and THR_SCHED_DEFAULT.

Definition at line 124 of file RT_ORBInitializer.h.

long const TAO_RT_ORBInitializer::scope_policy_ [private]

Scheduling scope flag.

Scheduling policy specified by the user through the -ORBScopePolicy option. This value is typically used by ACE thread creation functions. Legal values are THR_SCOPE_SYSTEM and THR_SCOPE_PROCESS.

Definition at line 133 of file RT_ORBInitializer.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:43:00 2010 for TAO_RTCORBA by  doxygen 1.4.7