summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/RTCORBA_POA_Helper.cpp
blob: 0464e39e0ad03be9b15ca5d0fa00d89cd99a3f1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// $Id$

#include "RTCORBA_POA_Helper.h"
#include "tao/RTCORBA/RTCORBA.h"
#include "tao/debug.h"
#include "orbsvcs/NotifyExtC.h"
#include "RTCORBA_Properties.h"

#if ! defined (__ACE_INLINE__)
#include "RTCORBA_POA_Helper.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID(RT_Notify, TAO_NS_RTCORBA_POA_Helper, "$Id$")

TAO_NS_RTCORBA_POA_Helper::~TAO_NS_RTCORBA_POA_Helper ()
{
}

void
TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL)
{
  char child_poa_name[32];
  ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10);

  this->init (parent_poa, child_poa_name, tp_params ACE_ENV_ARG_PARAMETER);
}

void
TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name, NotifyExt::ThreadPoolParams* tp_params ACE_ENV_ARG_DECL)
{
  CORBA::PolicyList policy_list (4);

  this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  RTCORBA::RTORB_var rt_orb = TAO_NS_RTCORBA_PROPERTIES::instance ()->rt_orb ();

  policy_list.length (3);
  policy_list[2] =
    rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
                                          0
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  if (tp_params != 0)
    {
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG, "Creating threadpool: static threads = %d, def. prio = %d\n", tp_params->static_threads, tp_params->default_priority));
        }

      // Create the thread-pool.
      RTCORBA::ThreadpoolId threadpool_id =
      rt_orb->create_threadpool (tp_params->stacksize,
                                 tp_params->static_threads,
                                 tp_params->dynamic_threads,
                                 tp_params->default_priority,
                                 tp_params->allow_request_buffering,
                                 tp_params->max_buffered_requests,
                                 tp_params->max_request_buffer_size
                                 ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;

      policy_list.length (4);
      policy_list[3] =
                rt_orb->create_threadpool_policy (threadpool_id
                                                          ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;
    }

  this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER);
}

void
TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL)
{
  char child_poa_name[32];
  ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10);

  this->init (parent_poa, child_poa_name, tpl_params ACE_ENV_ARG_PARAMETER);
}

void
TAO_NS_RTCORBA_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name, NotifyExt::ThreadPoolLanesParams* tpl_params ACE_ENV_ARG_DECL)
{
  CORBA::PolicyList policy_list (4);

  this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  RTCORBA::RTORB_var rt_orb = TAO_NS_RTCORBA_PROPERTIES::instance ()->rt_orb ();

  policy_list.length (3);
  policy_list[2] =
    rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
                                          0
                                          ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  if (tpl_params != 0)
    {
      // Populate RTCORBA Lanes.
      RTCORBA::ThreadpoolLanes lanes (tpl_params->lanes.length ());

      for (CORBA::ULong index = 0; index < tpl_params->lanes.length (); ++index)
        {
          if (TAO_debug_level > 0)
            {
              ACE_DEBUG ((LM_DEBUG, "Creating threadpool lane %d: priority = %d, static threads = %d\n",
                          index, tpl_params->lanes[index].lane_priority, tpl_params->lanes[index].static_threads));
            }

          lanes[index].lane_priority = tpl_params->lanes[index].lane_priority;
          lanes[index].static_threads = tpl_params->lanes[index].static_threads;
          lanes[index].dynamic_threads = tpl_params->lanes[index].dynamic_threads;
        }

      // Create the thread-pool.
      RTCORBA::ThreadpoolId threadpool_id =
        rt_orb->create_threadpool_with_lanes (tpl_params->stacksize,
                                              lanes,
                                              tpl_params->allow_borrowing,
                                              tpl_params->allow_request_buffering,
                                              tpl_params->max_buffered_requests,
                                              tpl_params->max_request_buffer_size
                                              ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;

      policy_list.length (4);
      policy_list[3] =
        rt_orb->create_threadpool_policy (threadpool_id
                                          ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;
    }

  this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER);
}