1 #include "tao/CSD_ThreadPool/CSD_TP_Strategy_Factory.h"
2 #include "tao/CSD_ThreadPool/CSD_TP_Strategy.h"
3 #include "tao/CSD_ThreadPool/CSD_ThreadPool.h"
4 #include "tao/CSD_Framework/CSD_Strategy_Repository.h"
6 #include "ace/Dynamic_Service.h"
7 #include "ace/OS_NS_strings.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 TAO::CSD::TP_Strategy_Factory::TP_Strategy_Factory()
16 TAO::CSD::TP_Strategy_Factory::~TP_Strategy_Factory()
22 TAO::CSD::TP_Strategy_Factory::init (int argc
,
25 ACE_TRACE ("TAO::CSD::TP_Strategy_Factory::init");
27 static int initialized
= 0;
29 // Only allow initialization once.
34 TAO_CSD_Strategy_Repository
*repo
=
35 ACE_Dynamic_Service
<TAO_CSD_Strategy_Repository
>::instance
36 (ACE_TEXT ("TAO_CSD_Strategy_Repository"));
40 TAO_CSD_ThreadPool::init ();
41 repo
= ACE_Dynamic_Service
<TAO_CSD_Strategy_Repository
>::instance
42 (ACE_TEXT ("TAO_CSD_Strategy_Repository"));
47 if (TAO_debug_level
> 0)
49 TAOLIB_DEBUG((LM_DEBUG
,
50 ACE_TEXT ("TAO (%P|%t) - TP_Strategy_Factory - ")
51 ACE_TEXT ("cannot initialize strategy repo\n")));
58 // Parse any service configurator parameters.
59 for (int curarg
= 0; curarg
< argc
; curarg
++)
61 if (ACE_OS::strcasecmp (argv
[curarg
],
62 ACE_TEXT("-CSDtp")) == 0)
65 unsigned long num_threads
= 1;
66 bool serialize_servants
= true;
74 // Parse the parameter
75 ACE_TCHAR
*sep
= ACE_OS::strchr (argv
[curarg
],':');
78 poa_name
= ACE_TEXT_ALWAYS_CHAR (argv
[curarg
]);
83 poa_name
= ACE_TEXT_ALWAYS_CHAR (argv
[curarg
]);
84 num_threads
= ACE_OS::strtol (sep
+ 1, &sep
, 10);
85 if (*sep
!= 0 && *sep
!= ':')
91 if (ACE_OS::strcasecmp (
92 sep
+ 1, ACE_TEXT_CHAR_TO_TCHAR ("OFF")) == 0)
94 serialize_servants
= false;
99 // Create the ThreadPool strategy for each named poa.
100 TP_Strategy
* strategy
= 0;
101 ACE_NEW_RETURN (strategy
,
102 TP_Strategy (num_threads
, serialize_servants
),
104 CSD_Framework::Strategy_var objref
= strategy
;
105 repo
->add_strategy (poa_name
, strategy
);
109 if (TAO_debug_level
> 0)
111 TAOLIB_ERROR ((LM_ERROR
,
112 ACE_TEXT("CSD_ORB_Loader: Unknown option ")
123 TAO_END_VERSIONED_NAMESPACE_DECL
125 ACE_FACTORY_NAMESPACE_DEFINE(TAO_CSD_TP
,
126 TAO_CSD_TP_Strategy_Factory
,
127 TAO::CSD::TP_Strategy_Factory
)
129 ACE_STATIC_SVC_DEFINE(TAO_CSD_TP_Strategy_Factory
,
130 ACE_TEXT("TAO_CSD_TP_Strategy_Factory"),
132 &ACE_SVC_NAME(TAO_CSD_TP_Strategy_Factory
),
133 ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ
,