#include <Thread_Pool.h>
Collaboration diagram for TAO_Thread_Pool_Manager:
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) |
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_ |
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 |
TAO_Thread_Pool_Manager::TAO_Thread_Pool_Manager | ( | TAO_ORB_Core & | orb_core | ) |
Constructor.
Definition at line 681 of file Thread_Pool.cpp.
00682 : orb_core_ (orb_core), 00683 thread_pools_ (), 00684 thread_pool_id_counter_ (1), 00685 lock_ () 00686 { 00687 }
TAO_Thread_Pool_Manager::~TAO_Thread_Pool_Manager | ( | void | ) |
Destructor.
Definition at line 689 of file Thread_Pool.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and thread_pools_.
00690 { 00691 // Delete all the pools. 00692 for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin (); 00693 iterator != this->thread_pools_.end (); 00694 ++iterator) 00695 delete (*iterator).int_id_; 00696 }
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 746 of file Thread_Pool.cpp.
References create_threadpool_i(), and TAO_THREAD_POOL_MANAGER_GUARD.
Referenced by TAO_RT_ORB::create_threadpool().
00755 { 00756 TAO_THREAD_POOL_MANAGER_GUARD; 00757 00758 return this->create_threadpool_i (stacksize, 00759 static_threads, 00760 dynamic_threads, 00761 default_priority, 00762 allow_request_buffering, 00763 max_buffered_requests, 00764 max_request_buffer_size, 00765 lifespan, 00766 dynamic_thread_time); 00767 }
RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool_helper | ( | TAO_Thread_Pool * | thread_pool | ) | [private] |
Definition at line 891 of file Thread_Pool.cpp.
References CORBA::SystemException::_tao_minor_code(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), CORBA::COMPLETED_NO, TAO_Thread_Pool::create_static_threads(), TAO_Thread_Pool::finalize(), TAO_Thread_Pool::open(), ACE_Auto_Basic_Ptr< X >::release(), TAO_RTCORBA_THREAD_CREATION_LOCATION_CODE, thread_pool_id_counter_, and thread_pools_.
Referenced by create_threadpool_i(), and create_threadpool_with_lanes_i().
00892 { 00893 // Make sure of safe deletion in case of errors. 00894 auto_ptr<TAO_Thread_Pool> safe_thread_pool (thread_pool); 00895 00896 // Open the pool. 00897 thread_pool->open (); 00898 00899 // Create the static threads. 00900 int result = thread_pool->create_static_threads (); 00901 00902 // Throw exception in case of errors. 00903 if (result != 0) 00904 { 00905 // Finalize thread pool related resources. 00906 thread_pool->finalize (); 00907 00908 throw ::CORBA::INTERNAL ( 00909 CORBA::SystemException::_tao_minor_code ( 00910 TAO_RTCORBA_THREAD_CREATION_LOCATION_CODE, 00911 errno), 00912 CORBA::COMPLETED_NO); 00913 } 00914 00915 // Bind thread to internal table. 00916 result = 00917 this->thread_pools_.bind (this->thread_pool_id_counter_, 00918 thread_pool); 00919 00920 // Throw exceptin in case of errors. 00921 if (result != 0) 00922 throw ::CORBA::INTERNAL (); 00923 00924 // 00925 // Success. 00926 // 00927 00928 // No need to delete thread pool. 00929 safe_thread_pool.release (); 00930 00931 // Return current counter and perform post-increment. 00932 return this->thread_pool_id_counter_++; 00933 }
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 829 of file Thread_Pool.cpp.
References ACE_NEW_THROW_EX, and create_threadpool_helper().
Referenced by create_threadpool().
00838 { 00839 // Create the thread pool. 00840 TAO_Thread_Pool *thread_pool = 0; 00841 00842 ACE_NEW_THROW_EX (thread_pool, 00843 TAO_Thread_Pool (*this, 00844 this->thread_pool_id_counter_, 00845 stacksize, 00846 static_threads, 00847 dynamic_threads, 00848 default_priority, 00849 allow_request_buffering, 00850 max_buffered_requests, 00851 max_request_buffer_size, 00852 lifespan, 00853 dynamic_thread_time 00854 ), 00855 CORBA::NO_MEMORY ()); 00856 00857 return this->create_threadpool_helper (thread_pool); 00858 }
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 770 of file Thread_Pool.cpp.
References create_threadpool_with_lanes_i(), and TAO_THREAD_POOL_MANAGER_GUARD.
Referenced by TAO_RT_ORB::create_threadpool_with_lanes().
00778 { 00779 TAO_THREAD_POOL_MANAGER_GUARD; 00780 00781 return this->create_threadpool_with_lanes_i (stacksize, 00782 lanes, 00783 allow_borrowing, 00784 allow_request_buffering, 00785 max_buffered_requests, 00786 max_request_buffer_size, 00787 lifespan, 00788 dynamic_thread_time); 00789 }
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 861 of file Thread_Pool.cpp.
References ACE_NEW_THROW_EX, and create_threadpool_helper().
Referenced by create_threadpool_with_lanes().
00869 { 00870 // Create the thread pool. 00871 TAO_Thread_Pool *thread_pool = 0; 00872 00873 ACE_NEW_THROW_EX (thread_pool, 00874 TAO_Thread_Pool (*this, 00875 this->thread_pool_id_counter_, 00876 stacksize, 00877 lanes, 00878 allow_borrowing, 00879 allow_request_buffering, 00880 max_buffered_requests, 00881 max_request_buffer_size, 00882 lifespan, 00883 dynamic_thread_time 00884 ), 00885 CORBA::NO_MEMORY ()); 00886 00887 return this->create_threadpool_helper (thread_pool); 00888 }
void TAO_Thread_Pool_Manager::destroy_threadpool | ( | RTCORBA::ThreadpoolId | threadpool | ) |
Destroy a threadpool.
Definition at line 792 of file Thread_Pool.cpp.
References TAO_Thread_Pool::finalize(), TAO_Thread_Pool::shutdown_reactor(), TAO_Thread_Pool::shutting_down(), TAO_THREAD_POOL_MANAGER_GUARD, thread_pools_, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(), and TAO_Thread_Pool::wait().
Referenced by TAO_RT_ORB::destroy_threadpool().
00793 { 00794 TAO_Thread_Pool *tao_thread_pool = 0; 00795 00796 // The guard is just for the map, don't do a wait inside the guard, because 00797 // during the wait other threads can try to access the thread pool manager 00798 // also, this can be one of the threads we are waiting for, which then 00799 // results in a deadlock 00800 { 00801 TAO_THREAD_POOL_MANAGER_GUARD; 00802 00803 // Unbind the thread pool from the map. 00804 int const result = this->thread_pools_.unbind (threadpool, tao_thread_pool); 00805 00806 // If the thread pool is not found in our map. 00807 if (result != 0) 00808 throw RTCORBA::RTORB::InvalidThreadpool (); 00809 } 00810 00811 // Mark the thread pool that we are shutting down. 00812 tao_thread_pool->shutting_down (); 00813 00814 // Shutdown reactor. 00815 tao_thread_pool->shutdown_reactor (); 00816 00817 // Wait for the threads. 00818 tao_thread_pool->wait (); 00819 00820 // Finalize resources. 00821 tao_thread_pool->finalize (); 00822 00823 // Delete the thread pool. 00824 delete tao_thread_pool; 00825 00826 }
void TAO_Thread_Pool_Manager::finalize | ( | void | ) |
Finalize the resources.
Definition at line 699 of file Thread_Pool.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and thread_pools_.
Referenced by TAO_RT_Thread_Lane_Resources_Manager::finalize().
00700 { 00701 // Finalize all the pools. 00702 for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin (); 00703 iterator != this->thread_pools_.end (); 00704 ++iterator) 00705 (*iterator).int_id_->finalize (); 00706 }
TAO_Thread_Pool * TAO_Thread_Pool_Manager::get_threadpool | ( | RTCORBA::ThreadpoolId | thread_pool_id | ) |
Definition at line 936 of file Thread_Pool.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), TAO_THREAD_POOL_MANAGER_GUARD, and thread_pools_.
00937 { 00938 TAO_THREAD_POOL_MANAGER_GUARD; 00939 00940 TAO_Thread_Pool *thread_pool = 0; 00941 int const result = thread_pools_.find (thread_pool_id, thread_pool); 00942 00943 ACE_UNUSED_ARG (result); 00944 00945 return thread_pool; 00946 }
int TAO_Thread_Pool_Manager::is_collocated | ( | const TAO_MProfile & | mprofile | ) |
Does mprofile belong to us?
Definition at line 729 of file Thread_Pool.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and thread_pools_.
Referenced by TAO_RT_Thread_Lane_Resources_Manager::is_collocated().
00730 { 00731 // Finalize all the pools. 00732 for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin (); 00733 iterator != this->thread_pools_.end (); 00734 ++iterator) 00735 { 00736 int const result = (*iterator).int_id_->is_collocated (mprofile); 00737 00738 if (result) 00739 return result; 00740 } 00741 00742 return 0; 00743 }
TAO_ORB_Core & TAO_Thread_Pool_Manager::orb_core | ( | void | ) | const |
Definition at line 949 of file Thread_Pool.cpp.
References orb_core_.
Referenced by TAO_Thread_Lane::create_threads_i(), TAO_Thread_Lane::new_dynamic_thread(), TAO_Thread_Lane::open(), TAO_Thread_Pool_Threads::svc(), and TAO_Thread_Lane::validate_and_map_priority().
00950 { 00951 return this->orb_core_; 00952 }
void TAO_Thread_Pool_Manager::shutdown_reactor | ( | void | ) |
Shutdown the reactor.
Definition at line 709 of file Thread_Pool.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and thread_pools_.
Referenced by TAO_RT_Thread_Lane_Resources_Manager::shutdown_reactor().
00710 { 00711 // Finalize all the pools. 00712 for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin (); 00713 iterator != this->thread_pools_.end (); 00714 ++iterator) 00715 (*iterator).int_id_->shutdown_reactor (); 00716 }
void TAO_Thread_Pool_Manager::wait | ( | void | ) |
Wait for threads to exit.
Definition at line 719 of file Thread_Pool.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and thread_pools_.
00720 { 00721 // Finalize all the pools. 00722 for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin (); 00723 iterator != this->thread_pools_.end (); 00724 ++iterator) 00725 (*iterator).int_id_->wait (); 00726 }
Definition at line 452 of file Thread_Pool.h.
TAO_ORB_Core& TAO_Thread_Pool_Manager::orb_core_ [private] |
RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::thread_pool_id_counter_ [private] |
Definition at line 450 of file Thread_Pool.h.
Referenced by create_threadpool_helper(), destroy_threadpool(), finalize(), get_threadpool(), is_collocated(), shutdown_reactor(), wait(), and ~TAO_Thread_Pool_Manager().