Class for managing thread pools. More...
#include <Thread_Pool.h>

Public Types | |
| typedef ACE_Hash_Map_Manager < RTCORBA::ThreadpoolId, TAO_Thread_Pool *, ACE_Null_Mutex > | THREAD_POOLS |
| Collection of thread pools. | |
Public Member Functions | |
| TAO_Thread_Pool_Manager (TAO_ORB_Core &orb_core) | |
| Constructor. | |
| ~TAO_Thread_Pool_Manager (void) | |
| Destructor. | |
| void | finalize (void) |
| Finalize the resources. | |
| void | shutdown_reactor (void) |
| Shutdown the reactor. | |
| void | wait (void) |
| Wait for threads to exit. | |
| int | is_collocated (const TAO_MProfile &mprofile) |
| Does mprofile belong to us? | |
| RTCORBA::ThreadpoolId | create_threadpool (CORBA::ULong stacksize, CORBA::ULong static_threads, CORBA::ULong dynamic_threads, RTCORBA::Priority default_priority, CORBA::Boolean allow_request_buffering, CORBA::ULong max_buffered_requests, CORBA::ULong max_request_buffer_size, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time) |
| Create a threadpool without lanes. | |
| RTCORBA::ThreadpoolId | create_threadpool_with_lanes (CORBA::ULong stacksize, const RTCORBA::ThreadpoolLanes &lanes, CORBA::Boolean allow_borrowing, CORBA::Boolean allow_request_buffering, CORBA::ULong max_buffered_requests, CORBA::ULong max_request_buffer_size, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time) |
| Create a threadpool with lanes. | |
| void | destroy_threadpool (RTCORBA::ThreadpoolId threadpool) |
| Destroy a threadpool. | |
| TAO_Thread_Pool * | get_threadpool (RTCORBA::ThreadpoolId thread_pool_id) |
Private Attributes | |
| TAO_ORB_Core & | orb_core_ |
| THREAD_POOLS | thread_pools_ |
| RTCORBA::ThreadpoolId | thread_pool_id_counter_ |
| TAO_SYNCH_MUTEX | lock_ |
Accessors | |
|
| |
| TAO_ORB_Core & | orb_core (void) const |
Helpers | |
|
| |
| RTCORBA::ThreadpoolId | create_threadpool_i (CORBA::ULong stacksize, CORBA::ULong static_threads, CORBA::ULong dynamic_threads, RTCORBA::Priority default_priority, CORBA::Boolean allow_request_buffering, CORBA::ULong max_buffered_requests, CORBA::ULong max_request_buffer_size, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time) |
| RTCORBA::ThreadpoolId | create_threadpool_with_lanes_i (CORBA::ULong stacksize, const RTCORBA::ThreadpoolLanes &lanes, CORBA::Boolean allow_borrowing, CORBA::Boolean allow_request_buffering, CORBA::ULong max_buffered_requests, CORBA::ULong max_request_buffer_size, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time) |
| RTCORBA::ThreadpoolId | create_threadpool_helper (TAO_Thread_Pool *thread_pool) |
Class for managing thread pools.
Definition at line 358 of file Thread_Pool.h.
| typedef ACE_Hash_Map_Manager<RTCORBA::ThreadpoolId, TAO_Thread_Pool *, ACE_Null_Mutex> TAO_Thread_Pool_Manager::THREAD_POOLS |
Collection of thread pools.
Definition at line 409 of file Thread_Pool.h.
| TAO_Thread_Pool_Manager::TAO_Thread_Pool_Manager | ( | TAO_ORB_Core & | orb_core | ) |
Constructor.
Definition at line 684 of file Thread_Pool.cpp.
: orb_core_ (orb_core), thread_pools_ (), thread_pool_id_counter_ (1), lock_ () { }
| TAO_Thread_Pool_Manager::~TAO_Thread_Pool_Manager | ( | void | ) |
Destructor.
Definition at line 692 of file Thread_Pool.cpp.
{
// Delete all the pools.
for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin ();
iterator != this->thread_pools_.end ();
++iterator)
delete (*iterator).int_id_;
}
| RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool | ( | CORBA::ULong | stacksize, | |
| CORBA::ULong | static_threads, | |||
| CORBA::ULong | dynamic_threads, | |||
| RTCORBA::Priority | default_priority, | |||
| CORBA::Boolean | allow_request_buffering, | |||
| CORBA::ULong | max_buffered_requests, | |||
| CORBA::ULong | max_request_buffer_size, | |||
| TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan | lifespan, | |||
| ACE_Time_Value const & | dynamic_thread_time | |||
| ) |
Create a threadpool without lanes.
Definition at line 749 of file Thread_Pool.cpp.
{
TAO_THREAD_POOL_MANAGER_GUARD;
return this->create_threadpool_i (stacksize,
static_threads,
dynamic_threads,
default_priority,
allow_request_buffering,
max_buffered_requests,
max_request_buffer_size,
lifespan,
dynamic_thread_time);
}
| RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool_helper | ( | TAO_Thread_Pool * | thread_pool | ) | [private] |
Definition at line 894 of file Thread_Pool.cpp.
{
// Make sure of safe deletion in case of errors.
auto_ptr<TAO_Thread_Pool> safe_thread_pool (thread_pool);
// Open the pool.
thread_pool->open ();
// Create the static threads.
int result = thread_pool->create_static_threads ();
// Throw exception in case of errors.
if (result != 0)
{
// Finalize thread pool related resources.
thread_pool->finalize ();
throw ::CORBA::INTERNAL (
CORBA::SystemException::_tao_minor_code (
TAO_RTCORBA_THREAD_CREATION_LOCATION_CODE,
errno),
CORBA::COMPLETED_NO);
}
// Bind thread to internal table.
result =
this->thread_pools_.bind (this->thread_pool_id_counter_,
thread_pool);
// Throw exceptin in case of errors.
if (result != 0)
throw ::CORBA::INTERNAL ();
//
// Success.
//
// No need to delete thread pool.
safe_thread_pool.release ();
// Return current counter and perform post-increment.
return this->thread_pool_id_counter_++;
}
| RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool_i | ( | CORBA::ULong | stacksize, | |
| CORBA::ULong | static_threads, | |||
| CORBA::ULong | dynamic_threads, | |||
| RTCORBA::Priority | default_priority, | |||
| CORBA::Boolean | allow_request_buffering, | |||
| CORBA::ULong | max_buffered_requests, | |||
| CORBA::ULong | max_request_buffer_size, | |||
| TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan | lifespan, | |||
| ACE_Time_Value const & | dynamic_thread_time | |||
| ) | [private] |
Definition at line 832 of file Thread_Pool.cpp.
{
// Create the thread pool.
TAO_Thread_Pool *thread_pool = 0;
ACE_NEW_THROW_EX (thread_pool,
TAO_Thread_Pool (*this,
this->thread_pool_id_counter_,
stacksize,
static_threads,
dynamic_threads,
default_priority,
allow_request_buffering,
max_buffered_requests,
max_request_buffer_size,
lifespan,
dynamic_thread_time
),
CORBA::NO_MEMORY ());
return this->create_threadpool_helper (thread_pool);
}
| RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool_with_lanes | ( | CORBA::ULong | stacksize, | |
| const RTCORBA::ThreadpoolLanes & | lanes, | |||
| CORBA::Boolean | allow_borrowing, | |||
| CORBA::Boolean | allow_request_buffering, | |||
| CORBA::ULong | max_buffered_requests, | |||
| CORBA::ULong | max_request_buffer_size, | |||
| TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan | lifespan, | |||
| ACE_Time_Value const & | dynamic_thread_time | |||
| ) |
Create a threadpool with lanes.
Definition at line 773 of file Thread_Pool.cpp.
{
TAO_THREAD_POOL_MANAGER_GUARD;
return this->create_threadpool_with_lanes_i (stacksize,
lanes,
allow_borrowing,
allow_request_buffering,
max_buffered_requests,
max_request_buffer_size,
lifespan,
dynamic_thread_time);
}
| RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool_with_lanes_i | ( | CORBA::ULong | stacksize, | |
| const RTCORBA::ThreadpoolLanes & | lanes, | |||
| CORBA::Boolean | allow_borrowing, | |||
| CORBA::Boolean | allow_request_buffering, | |||
| CORBA::ULong | max_buffered_requests, | |||
| CORBA::ULong | max_request_buffer_size, | |||
| TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan | lifespan, | |||
| ACE_Time_Value const & | dynamic_thread_time | |||
| ) | [private] |
Definition at line 864 of file Thread_Pool.cpp.
{
// Create the thread pool.
TAO_Thread_Pool *thread_pool = 0;
ACE_NEW_THROW_EX (thread_pool,
TAO_Thread_Pool (*this,
this->thread_pool_id_counter_,
stacksize,
lanes,
allow_borrowing,
allow_request_buffering,
max_buffered_requests,
max_request_buffer_size,
lifespan,
dynamic_thread_time
),
CORBA::NO_MEMORY ());
return this->create_threadpool_helper (thread_pool);
}
| void TAO_Thread_Pool_Manager::destroy_threadpool | ( | RTCORBA::ThreadpoolId | threadpool | ) |
Destroy a threadpool.
Definition at line 795 of file Thread_Pool.cpp.
{
TAO_Thread_Pool *tao_thread_pool = 0;
// The guard is just for the map, don't do a wait inside the guard, because
// during the wait other threads can try to access the thread pool manager
// also, this can be one of the threads we are waiting for, which then
// results in a deadlock
{
TAO_THREAD_POOL_MANAGER_GUARD;
// Unbind the thread pool from the map.
int const result = this->thread_pools_.unbind (threadpool, tao_thread_pool);
// If the thread pool is not found in our map.
if (result != 0)
throw RTCORBA::RTORB::InvalidThreadpool ();
}
// Mark the thread pool that we are shutting down.
tao_thread_pool->shutting_down ();
// Shutdown reactor.
tao_thread_pool->shutdown_reactor ();
// Wait for the threads.
tao_thread_pool->wait ();
// Finalize resources.
tao_thread_pool->finalize ();
// Delete the thread pool.
delete tao_thread_pool;
}
| void TAO_Thread_Pool_Manager::finalize | ( | void | ) |
Finalize the resources.
Definition at line 702 of file Thread_Pool.cpp.
{
// Finalize all the pools.
for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin ();
iterator != this->thread_pools_.end ();
++iterator)
(*iterator).int_id_->finalize ();
}
| TAO_Thread_Pool * TAO_Thread_Pool_Manager::get_threadpool | ( | RTCORBA::ThreadpoolId | thread_pool_id | ) |
Definition at line 939 of file Thread_Pool.cpp.
{
TAO_THREAD_POOL_MANAGER_GUARD;
TAO_Thread_Pool *thread_pool = 0;
int const result = thread_pools_.find (thread_pool_id, thread_pool);
ACE_UNUSED_ARG (result);
return thread_pool;
}
| int TAO_Thread_Pool_Manager::is_collocated | ( | const TAO_MProfile & | mprofile | ) |
Does mprofile belong to us?
Definition at line 732 of file Thread_Pool.cpp.
{
// Finalize all the pools.
for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin ();
iterator != this->thread_pools_.end ();
++iterator)
{
int const result = (*iterator).int_id_->is_collocated (mprofile);
if (result)
return result;
}
return 0;
}
| TAO_ORB_Core & TAO_Thread_Pool_Manager::orb_core | ( | void | ) | const |
Definition at line 952 of file Thread_Pool.cpp.
{
return this->orb_core_;
}
| void TAO_Thread_Pool_Manager::shutdown_reactor | ( | void | ) |
Shutdown the reactor.
Definition at line 712 of file Thread_Pool.cpp.
{
// Finalize all the pools.
for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin ();
iterator != this->thread_pools_.end ();
++iterator)
(*iterator).int_id_->shutdown_reactor ();
}
| void TAO_Thread_Pool_Manager::wait | ( | void | ) |
Wait for threads to exit.
Definition at line 722 of file Thread_Pool.cpp.
{
// Finalize all the pools.
for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin ();
iterator != this->thread_pools_.end ();
++iterator)
(*iterator).int_id_->wait ();
}
TAO_SYNCH_MUTEX TAO_Thread_Pool_Manager::lock_ [private] |
Definition at line 452 of file Thread_Pool.h.
TAO_ORB_Core& TAO_Thread_Pool_Manager::orb_core_ [private] |
Definition at line 448 of file Thread_Pool.h.
RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::thread_pool_id_counter_ [private] |
Definition at line 451 of file Thread_Pool.h.
Definition at line 450 of file Thread_Pool.h.
1.7.0