Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / examples / RTCORBA / Activity / POA_Holder.cpp
blob581993d6c7773ef50a3d639fbbdc4d0d9a46121a
1 #include "POA_Holder.h"
2 #include "tao/debug.h"
3 #include "ace/Log_Msg.h"
5 POA_Holder::POA_Holder ()
6 : priority_model_ (RTCORBA::CLIENT_PROPAGATED),
7 server_priority_ (0)
11 int
12 POA_Holder::init (ACE_Arg_Shifter& arg_shifter)
14 const ACE_TCHAR *current_arg = 0;
16 POA_name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // Read the name of the POA
17 arg_shifter.consume_arg ();
19 while (arg_shifter.is_anything_left ())
21 if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-PriorityModel"))))
23 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("CLIENT")) == 0)
24 priority_model_ = RTCORBA::CLIENT_PROPAGATED;
25 else
26 priority_model_ = RTCORBA::SERVER_DECLARED;
27 arg_shifter.consume_arg ();
29 server_priority_ = ACE_OS::atoi (current_arg);
30 arg_shifter.consume_arg ();
32 else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Lanes"))))
34 int lanecount = ACE_OS::atoi (current_arg);
35 lanes_.length (lanecount);
36 arg_shifter.consume_arg ();
38 int l_index = 0;
39 //parse lane values ...
40 while (arg_shifter.is_anything_left ())
42 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Lane")) == 0)
44 arg_shifter.consume_arg ();
46 // read priority
47 lanes_[l_index].lane_priority = ACE_OS::atoi (arg_shifter.get_current ());
48 arg_shifter.consume_arg ();
50 // static thread count
51 lanes_[l_index].static_threads = ACE_OS::atoi (arg_shifter.get_current ());
52 arg_shifter.consume_arg ();
54 // dynamic thread count
55 lanes_[l_index].dynamic_threads = ACE_OS::atoi (arg_shifter.get_current ());
56 arg_shifter.consume_arg ();
58 //if (TAO_debug_level > 0)
59 ACE_DEBUG ((LM_DEBUG, "lane parsed - %d, %d, %d\n",
60 lanes_[l_index].lane_priority,
61 lanes_[l_index].static_threads,
62 lanes_[l_index].dynamic_threads));
63 l_index++;
65 else
66 break;
67 } /* while -- lane values */
68 } /* if -Lanes */
69 else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Bands"))))
71 int bandcount = ACE_OS::atoi (current_arg);
72 bands_.length (bandcount);
73 arg_shifter.consume_arg ();
75 int b_index = 0;
76 //parse band values ...
77 while (arg_shifter.is_anything_left ())
79 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Band")) == 0)
81 arg_shifter.consume_arg ();
83 // read low
84 bands_[b_index].low = ACE_OS::atoi (arg_shifter.get_current ());
85 arg_shifter.consume_arg ();
87 // read high
88 bands_[b_index].high = ACE_OS::atoi (arg_shifter.get_current ());
89 arg_shifter.consume_arg ();
91 //if (TAO_debug_level > 0)
92 ACE_DEBUG ((LM_DEBUG, "band parsed - %d, %d\n",
93 bands_[b_index].low, bands_[b_index].high));
94 b_index++;
96 else
97 break;
98 } /* while -- Band values */
100 } /* if -Bands */
101 else // something else is showing up ...
103 return 0;
106 return 0;
109 void
110 POA_Holder::activate (RTCORBA::RTORB_ptr rt_orb, PortableServer::POA_ptr parent_poa)
113 lanes bands priomodel
115 if lanes create lanespolicy
116 if bands create bands policy
118 if lanes and bands , policy_list_length = 3
119 else
120 if lanes policy_list_length = 2
121 else
122 if bands policy_list_length = 2
123 else
124 policy_list_length = 1
128 CORBA::Policy_var priority_model_policy;
129 CORBA::Policy_var lanes_policy;
130 CORBA::Policy_var bands_policy;
132 // Create a priority model policy.
133 priority_model_policy =
134 rt_orb->create_priority_model_policy (priority_model_,
135 server_priority_);
137 if (lanes_.length () != 0)
139 // Create a thread-pool.
140 CORBA::ULong stacksize = 0;
141 CORBA::Boolean allow_request_buffering = 0;
142 CORBA::ULong max_buffered_requests = 0;
143 CORBA::ULong max_request_buffer_size = 0;
144 CORBA::Boolean allow_borrowing = 0;
145 // CORBA::ULong static_threads = 1;
146 // CORBA::ULong dynamic_threads = 0;
148 // Create the thread-pool.
149 RTCORBA::ThreadpoolId threadpool_id =
150 rt_orb->create_threadpool_with_lanes (stacksize,
151 lanes_,
152 allow_borrowing,
153 allow_request_buffering,
154 max_buffered_requests,
155 max_request_buffer_size);
158 // Create a thread-pool policy.
159 lanes_policy =
160 rt_orb->create_threadpool_policy (threadpool_id);
163 if (bands_.length () != 0)
165 // Create a bands policy.
166 bands_policy =
167 rt_orb->create_priority_banded_connection_policy (this->bands_);
170 CORBA::PolicyList poa_policy_list;
172 if (lanes_.length () == 0 && bands_.length () == 0)
174 poa_policy_list.length (1);
175 poa_policy_list[0] = priority_model_policy;
177 else if (lanes_.length () != 0 && bands_.length () == 0)
179 poa_policy_list.length (2);
180 poa_policy_list[0] = priority_model_policy;
181 poa_policy_list[1] = lanes_policy;
183 else if (lanes_.length () == 0 && bands_.length () != 0)
185 poa_policy_list.length (2);
186 poa_policy_list[0] = priority_model_policy;
187 poa_policy_list[1] = bands_policy;
189 else
191 poa_policy_list.length (3);
192 poa_policy_list[0] = priority_model_policy;
193 poa_policy_list[1] = lanes_policy;
194 poa_policy_list[2] = bands_policy;
197 if (TAO_debug_level > 0)
198 ACE_DEBUG ((LM_DEBUG, "creating POA %C\n", POA_name_.c_str ()));
200 // Get the POA Manager.
201 PortableServer::POAManager_var poa_manager =
202 parent_poa->the_POAManager ();
204 this->poa_ = parent_poa->create_POA (POA_name_.c_str (),
205 poa_manager.in (),
206 poa_policy_list);