1 #include "tao/RTCORBA/Thread_Pool.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #if ! defined (__ACE_INLINE__)
6 #include "tao/RTCORBA/Thread_Pool.inl"
7 #endif /* __ACE_INLINE__ */
9 #include "tao/Exception.h"
10 #include "tao/ORB_Core.h"
11 #include "tao/ORB_Core_TSS_Resources.h"
12 #include "tao/TSS_Resources.h"
14 #include "tao/Acceptor_Registry.h"
15 #include "tao/debug.h"
16 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
17 #include "tao/LF_Follower.h"
18 #include "tao/Leader_Follower.h"
21 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
23 TAO_RT_New_Leader_Generator::TAO_RT_New_Leader_Generator (
24 TAO_Thread_Lane
&lane
)
30 TAO_RT_New_Leader_Generator::no_leaders_available ()
32 // Request a new dynamic thread from the Thread Lane
33 return this->lane_
.new_dynamic_thread ();
36 TAO_Thread_Pool_Threads::TAO_Thread_Pool_Threads (TAO_Thread_Lane
&lane
)
37 : ACE_Task_Base (lane
.pool ().manager ().orb_core ().thr_mgr ()),
43 TAO_Thread_Pool_Threads::svc ()
45 TAO_ORB_Core
&orb_core
=
46 this->lane ().pool ().manager ().orb_core ();
48 if (orb_core
.has_shutdown ())
51 // Set TSS resources for this thread.
52 TAO_Thread_Pool_Threads::set_tss_resources (orb_core
, this->lane_
);
59 catch (const ::CORBA::Exception
& ex
)
61 // No point propagating this exception. Print it out.
62 TAOLIB_ERROR ((LM_ERROR
,
63 "orb->run() raised exception for thread %t\n"));
65 ex
._tao_print_exception ("");
72 TAO_Thread_Pool_Threads::run (TAO_ORB_Core
&orb_core
)
74 CORBA::ORB_ptr orb
= orb_core
.orb ();
83 TAO_Thread_Pool_Threads::set_tss_resources (TAO_ORB_Core
&orb_core
,
84 TAO_Thread_Lane
&thread_lane
)
86 /// Get the ORB_Core's TSS resources.
87 TAO_ORB_Core_TSS_Resources
&tss
=
88 *orb_core
.get_tss_resources ();
90 /// Set the lane attribute in TSS.
91 tss
.lane_
= &thread_lane
;
93 TAO_TSS_Resources::instance ()->rtcorba_current_priority_
94 = thread_lane
.lane_priority ();
97 TAO_Dynamic_Thread_Pool_Threads::TAO_Dynamic_Thread_Pool_Threads (TAO_Thread_Lane
&lane
)
98 : TAO_Thread_Pool_Threads (lane
)
103 TAO_Dynamic_Thread_Pool_Threads::run (TAO_ORB_Core
&orb_core
)
105 CORBA::ORB_ptr orb
= orb_core
.orb ();
107 switch (this->lane_
.lifespan ())
109 case TAO_RT_ORBInitializer::TAO_RTCORBA_DT_FIXED
:
111 ACE_Time_Value
tv_run (this->lane_
.dynamic_thread_time ());
115 case TAO_RT_ORBInitializer::TAO_RTCORBA_DT_IDLE
:
117 // A timeout is specified, run the ORB in an idle loop, if we
118 // don't handle any operations for the given timeout we just
119 // exit the loop and this thread ends itself.
120 ACE_Time_Value
tv (this->lane_
.dynamic_thread_time ());
121 while (!orb_core
.has_shutdown () && orb
->work_pending (tv
))
123 // Run the ORB for the specified timeout, this prevents looping
124 // between work_pending/handle_events
125 tv
= this->lane_
.dynamic_thread_time ();
127 // Reset the idle timeout
128 tv
= this->lane_
.dynamic_thread_time ();
132 case TAO_RT_ORBInitializer::TAO_RTCORBA_DT_INFINITIVE
:
134 // No timeout specified, run the ORB until it shutdowns
140 if (TAO_debug_level
> 7)
142 TAOLIB_DEBUG ((LM_DEBUG
,
143 ACE_TEXT ("TAO Process %P Pool %d Lane %d Thread %t\n")
144 ACE_TEXT ("Current number of dynamic threads left = %d; ")
145 ACE_TEXT ("RTCorba worker thread is ending!\n"),
146 this->lane_
.pool ().id (),
148 this->thr_count () - 1));
154 TAO_Thread_Lane::TAO_Thread_Lane (TAO_Thread_Pool
&pool
,
156 CORBA::Short lane_priority
,
157 CORBA::ULong static_threads
,
158 CORBA::ULong dynamic_threads
,
159 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
160 ACE_Time_Value
const &dynamic_thread_time
)
163 lane_priority_ (lane_priority
),
165 static_threads_number_ (static_threads
),
166 dynamic_threads_number_ (dynamic_threads
),
167 static_threads_ (*this),
168 dynamic_threads_ (*this),
169 new_thread_generator_ (*this),
170 resources_ (pool
.manager ().orb_core (),
171 &new_thread_generator_
),
172 native_priority_ (TAO_INVALID_PRIORITY
),
173 lifespan_ (lifespan
),
174 dynamic_thread_time_ (dynamic_thread_time
)
179 TAO_Thread_Lane::new_dynamic_thread ()
181 // Note that we are checking this condition below without the lock
183 if (this->dynamic_threads_
.thr_count () >= this->dynamic_threads_number_
)
186 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
,
191 TAO_Thread_Pool_Manager
&manager
= this->pool_
.manager ();
193 if (!manager
.orb_core ().has_shutdown () && !this->shutdown_
&&
194 this->dynamic_threads_
.thr_count () < this->dynamic_threads_number_
)
196 if (TAO_debug_level
> 0)
197 TAOLIB_DEBUG ((LM_DEBUG
,
198 ACE_TEXT ("TAO Process %P Pool %d Lane %d Thread %t\n")
199 ACE_TEXT ("Current number of dynamic threads = %d; ")
200 ACE_TEXT ("static threads = %d; max dynamic threads = %d\n")
201 ACE_TEXT ("No leaders available; creating new leader!\n"),
204 this->dynamic_threads_
.thr_count (),
205 this->static_threads_number_
,
206 this->dynamic_threads_number_
));
209 this->create_threads_i (this->dynamic_threads_
,
211 THR_BOUND
| THR_DETACHED
);
214 TAOLIB_ERROR_RETURN ((LM_ERROR
,
215 ACE_TEXT ("Pool %d Lane %d Thread %t: ")
216 ACE_TEXT ("cannot create dynamic thread\n"),
226 TAO_Thread_Lane::shutting_down ()
228 ACE_GUARD (TAO_SYNCH_MUTEX
,
232 // We are shutting down, this way we are not creating any more new dynamic
234 this->shutdown_
= true;
238 TAO_Thread_Lane::validate_and_map_priority ()
240 // Make sure that static_threads_number_ is not zero.
241 if (this->static_threads_number_
== 0)
242 throw ::CORBA::BAD_PARAM ();
244 // Check that the priority is in bounds.
245 if (this->lane_priority_
< RTCORBA::minPriority
246 // The line below will always be false unless the value of
247 // RTCORBA::maxPriority, which is now assigned the value of
248 // 32767, is changed in RTCORBA.pidl.
249 // || this->lane_priority_ > RTCORBA::maxPriority
252 throw ::CORBA::BAD_PARAM ();
255 CORBA::ORB_ptr orb
= this->pool_
.manager ().orb_core ().orb ();
257 // Get the priority mapping manager.
258 CORBA::Object_var obj
=
259 orb
->resolve_initial_references (TAO_OBJID_PRIORITYMAPPINGMANAGER
);
261 TAO_Priority_Mapping_Manager_var mapping_manager
=
262 TAO_Priority_Mapping_Manager::_narrow (obj
.in ());
264 RTCORBA::PriorityMapping
*pm
= mapping_manager
.in ()->mapping ();
266 // Map CORBA priority to native priority.
267 CORBA::Boolean
const result
=
268 pm
->to_native (this->lane_priority_
, this->native_priority_
);
271 throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_NO
);
273 if (TAO_debug_level
> 3)
275 TAOLIB_DEBUG ((LM_DEBUG
,
276 ACE_TEXT ("TAO (%P|%t) - creating thread at ")
277 ACE_TEXT ("(corba:native) priority %d:%d\n"),
278 this->lane_priority_
,
279 this->native_priority_
));
284 TAO_Thread_Lane::open ()
286 // Validate and map priority.
287 this->validate_and_map_priority ();
289 char pool_lane_id
[10];
290 TAO_ORB_Parameters
*params
=
291 this->pool ().manager ().orb_core ().orb_params ();
292 TAO_EndpointSet endpoint_set
;
294 // Create a string just *:* which means all pools all thread id's
295 ACE_OS::sprintf (pool_lane_id
,
298 // Get the endpoints for all
299 params
->get_endpoint_set (pool_lane_id
, endpoint_set
);
301 // Create a string with pool:* which means all lanes for this pool
302 ACE_OS::sprintf (pool_lane_id
,
304 this->pool ().id ());
306 // Get the endpoints for this pool.
307 params
->get_endpoint_set (pool_lane_id
, endpoint_set
);
309 // Create a string with *:lane which means a lan of all pools
310 ACE_OS::sprintf (pool_lane_id
,
314 // Get the endpoints for this lane.
315 params
->get_endpoint_set (pool_lane_id
, endpoint_set
);
317 // Create a string with the pool:thread id.
318 ACE_OS::sprintf (pool_lane_id
,
323 // Get the endpoints for this lane.
324 params
->get_endpoint_set (pool_lane_id
, endpoint_set
);
326 bool ignore_address
= false;
328 if (endpoint_set
.is_empty ())
330 // If endpoints are not specified for this lane, use the
331 // endpoints specified for the default lane but ignore their
333 params
->get_endpoint_set (TAO_DEFAULT_LANE
, endpoint_set
);
335 ignore_address
= true;
339 // If endpoints are specified for this lane, use them with their
341 ignore_address
= false;
344 // Open the acceptor registry.
346 this->resources_
.open_acceptor_registry (endpoint_set
, ignore_address
);
349 throw ::CORBA::INTERNAL (
350 CORBA::SystemException::_tao_minor_code (
351 TAO_ACCEPTOR_REGISTRY_OPEN_LOCATION_CODE
,
353 CORBA::COMPLETED_NO
);
356 TAO_Thread_Lane::~TAO_Thread_Lane ()
361 TAO_Thread_Lane::finalize ()
363 // Finalize resources.
364 this->resources_
.finalize ();
368 TAO_Thread_Lane::shutdown_reactor ()
370 this->resources_
.shutdown_reactor ();
374 TAO_Thread_Lane::wait ()
376 this->static_threads_
.wait ();
377 this->dynamic_threads_
.wait ();
381 TAO_Thread_Lane::is_collocated (const TAO_MProfile
&mprofile
)
383 return this->resources_
.is_collocated (mprofile
);
387 TAO_Thread_Lane::current_threads () const
389 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
,
394 return static_cast<CORBA::ULong
> (this->static_threads_
.thr_count () +
395 this->dynamic_threads_
.thr_count ());
400 TAO_Thread_Lane::create_static_threads ()
402 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
,
407 // Create static threads.
408 return this->create_threads_i (this->static_threads_
,
409 this->static_threads_number_
,
410 THR_NEW_LWP
| THR_JOINABLE
);
414 TAO_Thread_Lane::create_dynamic_threads (CORBA::ULong number_of_threads
)
416 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
,
421 return this->create_threads_i (this->dynamic_threads_
,
423 THR_BOUND
| THR_DETACHED
);
427 TAO_Thread_Lane::create_threads_i (TAO_Thread_Pool_Threads
&thread_pool
,
428 CORBA::ULong number_of_threads
,
431 // Overwritten parameters.
432 int force_active
= 1;
434 // Default parameters.
435 int default_grp_id
= -1;
436 ACE_Task_Base
*default_task
= 0;
437 ACE_hthread_t
*default_thread_handles
= 0;
438 void **default_stack
= 0;
440 // Setting stack size.
441 size_t *stack_size_array
= 0;
442 ACE_NEW_RETURN (stack_size_array
,
443 size_t[number_of_threads
],
447 index
!= number_of_threads
;
449 stack_size_array
[index
] =
450 this->pool ().stack_size ();
452 // Make sure the dynamically created stack size array is properly
454 std::unique_ptr
<size_t[]> auto_stack_size_array (stack_size_array
);
456 TAO_ORB_Core
&orb_core
=
457 this->pool ().manager ().orb_core ();
461 orb_core
.orb_params ()->thread_creation_flags ();
463 // Activate the threads.
465 thread_pool
.activate (flags
,
468 this->native_priority_
,
471 default_thread_handles
,
481 TAO_Thread_Pool::TAO_Thread_Pool (TAO_Thread_Pool_Manager
&manager
,
483 CORBA::ULong stack_size
,
484 CORBA::ULong static_threads
,
485 CORBA::ULong dynamic_threads
,
486 CORBA::Short default_priority
,
487 CORBA::Boolean allow_request_buffering
,
488 CORBA::ULong max_buffered_requests
,
489 CORBA::ULong max_request_buffer_size
,
490 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
491 ACE_Time_Value
const &dynamic_thread_time
)
492 : manager_ (manager
),
494 stack_size_ (stack_size
),
495 allow_borrowing_ (0),
496 allow_request_buffering_ (allow_request_buffering
),
497 max_buffered_requests_ (max_buffered_requests
),
498 max_request_buffer_size_ (max_request_buffer_size
),
499 // lifespan_ (lifespan),
500 dynamic_thread_time_ (dynamic_thread_time
),
502 number_of_lanes_ (1),
505 // No support for buffering.
506 if (allow_request_buffering
)
507 throw ::CORBA::NO_IMPLEMENT ();
510 ACE_NEW (this->lanes_
,
511 TAO_Thread_Lane
*[this->number_of_lanes_
]);
512 ACE_NEW (this->lanes_
[0],
513 TAO_Thread_Lane (*this,
519 dynamic_thread_time
));
522 TAO_Thread_Pool::TAO_Thread_Pool (TAO_Thread_Pool_Manager
&manager
,
524 CORBA::ULong stack_size
,
525 const RTCORBA::ThreadpoolLanes
&lanes
,
526 CORBA::Boolean allow_borrowing
,
527 CORBA::Boolean allow_request_buffering
,
528 CORBA::ULong max_buffered_requests
,
529 CORBA::ULong max_request_buffer_size
,
530 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
531 ACE_Time_Value
const &dynamic_thread_time
)
532 : manager_ (manager
),
534 stack_size_ (stack_size
),
535 allow_borrowing_ (allow_borrowing
),
536 allow_request_buffering_ (allow_request_buffering
),
537 max_buffered_requests_ (max_buffered_requests
),
538 max_request_buffer_size_ (max_request_buffer_size
),
539 // lifespan_ (lifespan),
540 dynamic_thread_time_ (dynamic_thread_time
),
542 number_of_lanes_ (lanes
.length ()),
545 // No support for buffering or borrowing.
546 if (allow_borrowing
||
547 allow_request_buffering
)
548 throw ::CORBA::NO_IMPLEMENT ();
550 // Create multiple lane.
551 ACE_NEW (this->lanes_
,
552 TAO_Thread_Lane
*[this->number_of_lanes_
]);
553 for (CORBA::ULong i
= 0;
554 i
!= this->number_of_lanes_
;
556 ACE_NEW (this->lanes_
[i
],
557 TAO_Thread_Lane (*this,
559 lanes
[i
].lane_priority
,
560 lanes
[i
].static_threads
,
561 lanes
[i
].dynamic_threads
,
563 dynamic_thread_time
));
567 TAO_Thread_Pool::open ()
569 // Open all the lanes.
570 for (CORBA::ULong i
= 0;
571 i
!= this->number_of_lanes_
;
574 this->lanes_
[i
]->open ();
578 TAO_Thread_Pool::~TAO_Thread_Pool ()
580 // Delete all the lanes.
581 for (CORBA::ULong i
= 0;
582 i
!= this->number_of_lanes_
;
584 delete this->lanes_
[i
];
586 delete[] this->lanes_
;
590 TAO_Thread_Pool::finalize ()
592 // Finalize all the lanes.
593 for (CORBA::ULong i
= 0;
594 i
!= this->number_of_lanes_
;
596 this->lanes_
[i
]->finalize ();
600 TAO_Thread_Pool::shutdown_reactor ()
602 // Finalize all the lanes.
603 for (CORBA::ULong i
= 0;
604 i
!= this->number_of_lanes_
;
606 this->lanes_
[i
]->shutdown_reactor ();
610 TAO_Thread_Pool::shutting_down ()
612 // Finalize all the lanes.
613 for (CORBA::ULong i
= 0;
614 i
!= this->number_of_lanes_
;
616 this->lanes_
[i
]->shutting_down ();
621 TAO_Thread_Pool::wait ()
623 // Finalize all the lanes.
624 for (CORBA::ULong i
= 0;
625 i
!= this->number_of_lanes_
;
627 this->lanes_
[i
]->wait ();
631 TAO_Thread_Pool::is_collocated (const TAO_MProfile
&mprofile
)
633 // Finalize all the lanes.
634 for (CORBA::ULong i
= 0;
635 i
!= this->number_of_lanes_
;
639 this->lanes_
[i
]->is_collocated (mprofile
);
649 TAO_Thread_Pool::create_static_threads ()
651 for (CORBA::ULong i
= 0;
652 i
!= this->number_of_lanes_
;
655 // Ask each lane to create its set of static threads.
656 int const result
= this->lanes_
[i
]->create_static_threads ();
658 // Return on failure.
667 #define TAO_THREAD_POOL_MANAGER_GUARD \
668 ACE_GUARD_THROW_EX ( \
673 CORBA::SystemException::_tao_minor_code ( \
676 CORBA::COMPLETED_NO));
678 TAO_Thread_Pool_Manager::TAO_Thread_Pool_Manager (TAO_ORB_Core
&orb_core
)
679 : orb_core_ (orb_core
),
681 thread_pool_id_counter_ (1),
686 TAO_Thread_Pool_Manager::~TAO_Thread_Pool_Manager ()
688 // Delete all the pools.
689 for (THREAD_POOLS::ITERATOR iterator
= this->thread_pools_
.begin ();
690 iterator
!= this->thread_pools_
.end ();
692 delete (*iterator
).int_id_
;
696 TAO_Thread_Pool_Manager::finalize ()
698 // Finalize all the pools.
699 for (THREAD_POOLS::ITERATOR iterator
= this->thread_pools_
.begin ();
700 iterator
!= this->thread_pools_
.end ();
702 (*iterator
).int_id_
->finalize ();
706 TAO_Thread_Pool_Manager::shutdown_reactor ()
708 // Finalize all the pools.
709 for (THREAD_POOLS::ITERATOR iterator
= this->thread_pools_
.begin ();
710 iterator
!= this->thread_pools_
.end ();
712 (*iterator
).int_id_
->shutdown_reactor ();
716 TAO_Thread_Pool_Manager::wait ()
718 // Finalize all the pools.
719 for (THREAD_POOLS::ITERATOR iterator
= this->thread_pools_
.begin ();
720 iterator
!= this->thread_pools_
.end ();
722 (*iterator
).int_id_
->wait ();
726 TAO_Thread_Pool_Manager::is_collocated (const TAO_MProfile
&mprofile
)
728 // Finalize all the pools.
729 for (THREAD_POOLS::ITERATOR iterator
= this->thread_pools_
.begin ();
730 iterator
!= this->thread_pools_
.end ();
733 int const result
= (*iterator
).int_id_
->is_collocated (mprofile
);
742 RTCORBA::ThreadpoolId
743 TAO_Thread_Pool_Manager::create_threadpool (CORBA::ULong stacksize
,
744 CORBA::ULong static_threads
,
745 CORBA::ULong dynamic_threads
,
746 RTCORBA::Priority default_priority
,
747 CORBA::Boolean allow_request_buffering
,
748 CORBA::ULong max_buffered_requests
,
749 CORBA::ULong max_request_buffer_size
,
750 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
751 ACE_Time_Value
const &dynamic_thread_time
)
753 TAO_THREAD_POOL_MANAGER_GUARD
;
755 return this->create_threadpool_i (stacksize
,
759 allow_request_buffering
,
760 max_buffered_requests
,
761 max_request_buffer_size
,
763 dynamic_thread_time
);
766 RTCORBA::ThreadpoolId
767 TAO_Thread_Pool_Manager::create_threadpool_with_lanes (CORBA::ULong stacksize
,
768 const RTCORBA::ThreadpoolLanes
& lanes
,
769 CORBA::Boolean allow_borrowing
,
770 CORBA::Boolean allow_request_buffering
,
771 CORBA::ULong max_buffered_requests
,
772 CORBA::ULong max_request_buffer_size
,
773 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
774 ACE_Time_Value
const &dynamic_thread_time
)
776 TAO_THREAD_POOL_MANAGER_GUARD
;
778 return this->create_threadpool_with_lanes_i (stacksize
,
781 allow_request_buffering
,
782 max_buffered_requests
,
783 max_request_buffer_size
,
785 dynamic_thread_time
);
789 TAO_Thread_Pool_Manager::destroy_threadpool (RTCORBA::ThreadpoolId threadpool
)
791 TAO_Thread_Pool
*tao_thread_pool
= 0;
793 // The guard is just for the map, don't do a wait inside the guard, because
794 // during the wait other threads can try to access the thread pool manager
795 // also, this can be one of the threads we are waiting for, which then
796 // results in a deadlock
798 TAO_THREAD_POOL_MANAGER_GUARD
;
800 // Unbind the thread pool from the map.
801 int const result
= this->thread_pools_
.unbind (threadpool
, tao_thread_pool
);
803 // If the thread pool is not found in our map.
805 throw RTCORBA::RTORB::InvalidThreadpool ();
808 // Mark the thread pool that we are shutting down.
809 tao_thread_pool
->shutting_down ();
812 tao_thread_pool
->shutdown_reactor ();
814 // Wait for the threads.
815 tao_thread_pool
->wait ();
817 // Finalize resources.
818 tao_thread_pool
->finalize ();
820 // Delete the thread pool.
821 delete tao_thread_pool
;
824 RTCORBA::ThreadpoolId
825 TAO_Thread_Pool_Manager::create_threadpool_i (CORBA::ULong stacksize
,
826 CORBA::ULong static_threads
,
827 CORBA::ULong dynamic_threads
,
828 RTCORBA::Priority default_priority
,
829 CORBA::Boolean allow_request_buffering
,
830 CORBA::ULong max_buffered_requests
,
831 CORBA::ULong max_request_buffer_size
,
832 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
833 ACE_Time_Value
const &dynamic_thread_time
)
835 // Create the thread pool.
836 TAO_Thread_Pool
*thread_pool
= 0;
838 ACE_NEW_THROW_EX (thread_pool
,
839 TAO_Thread_Pool (*this,
840 this->thread_pool_id_counter_
,
845 allow_request_buffering
,
846 max_buffered_requests
,
847 max_request_buffer_size
,
851 CORBA::NO_MEMORY ());
853 return this->create_threadpool_helper (thread_pool
);
856 RTCORBA::ThreadpoolId
857 TAO_Thread_Pool_Manager::create_threadpool_with_lanes_i (CORBA::ULong stacksize
,
858 const RTCORBA::ThreadpoolLanes
&lanes
,
859 CORBA::Boolean allow_borrowing
,
860 CORBA::Boolean allow_request_buffering
,
861 CORBA::ULong max_buffered_requests
,
862 CORBA::ULong max_request_buffer_size
,
863 TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan
,
864 ACE_Time_Value
const &dynamic_thread_time
)
866 // Create the thread pool.
867 TAO_Thread_Pool
*thread_pool
= 0;
869 ACE_NEW_THROW_EX (thread_pool
,
870 TAO_Thread_Pool (*this,
871 this->thread_pool_id_counter_
,
875 allow_request_buffering
,
876 max_buffered_requests
,
877 max_request_buffer_size
,
881 CORBA::NO_MEMORY ());
883 return this->create_threadpool_helper (thread_pool
);
886 RTCORBA::ThreadpoolId
887 TAO_Thread_Pool_Manager::create_threadpool_helper (TAO_Thread_Pool
*thread_pool
)
889 // Make sure of safe deletion in case of errors.
890 std::unique_ptr
<TAO_Thread_Pool
> safe_thread_pool (thread_pool
);
893 thread_pool
->open ();
895 // Create the static threads.
896 int result
= thread_pool
->create_static_threads ();
898 // Throw exception in case of errors.
901 // Finalize thread pool related resources.
902 thread_pool
->finalize ();
904 throw ::CORBA::INTERNAL (
905 CORBA::SystemException::_tao_minor_code (
906 TAO_RTCORBA_THREAD_CREATION_LOCATION_CODE
,
908 CORBA::COMPLETED_NO
);
911 // Bind thread to internal table.
913 this->thread_pools_
.bind (this->thread_pool_id_counter_
,
916 // Throw exceptin in case of errors.
918 throw ::CORBA::INTERNAL ();
924 // No need to delete thread pool.
925 safe_thread_pool
.release ();
927 // Return current counter and perform post-increment.
928 return this->thread_pool_id_counter_
++;
932 TAO_Thread_Pool_Manager::get_threadpool (RTCORBA::ThreadpoolId thread_pool_id
)
934 TAO_THREAD_POOL_MANAGER_GUARD
;
936 TAO_Thread_Pool
*thread_pool
= 0;
937 int const result
= thread_pools_
.find (thread_pool_id
, thread_pool
);
939 ACE_UNUSED_ARG (result
);
945 TAO_Thread_Pool_Manager::orb_core () const
947 return this->orb_core_
;
950 TAO_END_VERSIONED_NAMESPACE_DECL
952 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */