TAO_Thread_Pool Class Reference

Class representing the thread pool inside a thread pool manager. More...

#include <Thread_Pool.h>

Collaboration diagram for TAO_Thread_Pool:

Collaboration graph
[legend]
List of all members.

Accessors

TAO_Thread_Pool_Managermanager (void) const
CORBA::ULong id (void) const
CORBA::ULong stack_size (void) const
CORBA::Boolean allow_borrowing (void) const
CORBA::Boolean allow_request_buffering (void) const
CORBA::ULong max_buffered_requests (void) const
CORBA::ULong max_request_buffer_size (void) const
TAO_Thread_Lane ** lanes (void)
CORBA::ULong number_of_lanes (void) const

Public Member Functions

 TAO_Thread_Pool (TAO_Thread_Pool_Manager &manager, CORBA::ULong id, CORBA::ULong stack_size, CORBA::ULong static_threads, CORBA::ULong dynamic_threads, CORBA::Short default_priority, CORBA::Boolean allow_request_buffering, CORBA::ULong max_buffered_requests, CORBA::ULong max_request_buffer_size, ACE_Time_Value const &dynamic_thread_idle_timeout)
 Constructor (for pools without lanes).

 TAO_Thread_Pool (TAO_Thread_Pool_Manager &manager, CORBA::ULong id, CORBA::ULong stack_size, const RTCORBA::ThreadpoolLanes &lanes, CORBA::Boolean allow_borrowing, CORBA::Boolean allow_request_buffering, CORBA::ULong max_buffered_requests, CORBA::ULong max_request_buffer_size, ACE_Time_Value const &dynamic_thread_idle_timeout)
 Constructor (for pools with lanes).

 ~TAO_Thread_Pool (void)
 Destructor.

void open (void)
 Open the pool.

void finalize (void)
 Finalize the resources.

void shutdown_reactor (void)
 Shutdown the reactor.

void wait (void)
 Wait for threads to exit.

void shutting_down (void)
 Mark this thread pool that we are shutting down.

int is_collocated (const TAO_MProfile &mprofile)
 Does mprofile belong to us?

int create_static_threads (void)
 Create the static threads - only called once.

bool with_lanes (void) const
 Check if this thread pool has (explicit) lanes.


Private Attributes

TAO_Thread_Pool_Managermanager_
CORBA::ULong id_
CORBA::ULong stack_size_
CORBA::Boolean allow_borrowing_
CORBA::Boolean allow_request_buffering_
CORBA::ULong max_buffered_requests_
CORBA::ULong max_request_buffer_size_
ACE_Time_Value const  dynamic_thread_idle_timeout_
TAO_Thread_Lane ** lanes_
CORBA::ULong number_of_lanes_
bool with_lanes_

Detailed Description

Class representing the thread pool inside a thread pool manager.

Definition at line 254 of file Thread_Pool.h.


Constructor & Destructor Documentation

TAO_Thread_Pool::TAO_Thread_Pool TAO_Thread_Pool_Manager manager,
CORBA::ULong  id,
CORBA::ULong  stack_size,
CORBA::ULong  static_threads,
CORBA::ULong  dynamic_threads,
CORBA::Short  default_priority,
CORBA::Boolean  allow_request_buffering,
CORBA::ULong  max_buffered_requests,
CORBA::ULong  max_request_buffer_size,
ACE_Time_Value const &  dynamic_thread_idle_timeout
 

Constructor (for pools without lanes).

Definition at line 445 of file Thread_Pool.cpp.

References ACE_NEW.

00456   : manager_ (manager),
00457     id_ (id),
00458     stack_size_ (stack_size),
00459     allow_borrowing_ (0),
00460     allow_request_buffering_ (allow_request_buffering),
00461     max_buffered_requests_ (max_buffered_requests),
00462     max_request_buffer_size_ (max_request_buffer_size),
00463     dynamic_thread_idle_timeout_ (dynamic_thread_idle_timeout),
00464     lanes_ (0),
00465     number_of_lanes_ (1),
00466     with_lanes_ (false)
00467 {
00468   // No support for buffering.
00469   if (allow_request_buffering)
00470     throw ::CORBA::NO_IMPLEMENT ();
00471 
00472   // Create one lane.
00473   ACE_NEW (this->lanes_,
00474            TAO_Thread_Lane *[this->number_of_lanes_]);
00475   ACE_NEW (this->lanes_[0],
00476            TAO_Thread_Lane (*this,
00477                             0,
00478                             default_priority,
00479                             static_threads,
00480                             dynamic_threads,
00481                             dynamic_thread_idle_timeout
00482                            ));
00483 }

TAO_Thread_Pool::TAO_Thread_Pool TAO_Thread_Pool_Manager manager,
CORBA::ULong  id,
CORBA::ULong  stack_size,
const RTCORBA::ThreadpoolLanes lanes,
CORBA::Boolean  allow_borrowing,
CORBA::Boolean  allow_request_buffering,
CORBA::ULong  max_buffered_requests,
CORBA::ULong  max_request_buffer_size,
ACE_Time_Value const &  dynamic_thread_idle_timeout
 

Constructor (for pools with lanes).

Definition at line 485 of file Thread_Pool.cpp.

References ACE_NEW, number_of_lanes_, and RTCORBA::ThreadpoolLanes.

00495   : manager_ (manager),
00496     id_ (id),
00497     stack_size_ (stack_size),
00498     allow_borrowing_ (allow_borrowing),
00499     allow_request_buffering_ (allow_request_buffering),
00500     max_buffered_requests_ (max_buffered_requests),
00501     max_request_buffer_size_ (max_request_buffer_size),
00502     dynamic_thread_idle_timeout_ (dynamic_thread_idle_timeout),
00503     lanes_ (0),
00504     number_of_lanes_ (lanes.length ()),
00505     with_lanes_ (true)
00506 {
00507   // No support for buffering or borrowing.
00508   if (allow_borrowing ||
00509       allow_request_buffering)
00510     throw ::CORBA::NO_IMPLEMENT ();
00511 
00512   // Create multiple lane.
00513   ACE_NEW (this->lanes_,
00514            TAO_Thread_Lane *[this->number_of_lanes_]);
00515   for (CORBA::ULong i = 0;
00516        i != this->number_of_lanes_;
00517        ++i)
00518     ACE_NEW (this->lanes_[i],
00519              TAO_Thread_Lane (*this,
00520                               i,
00521                               lanes[i].lane_priority,
00522                               lanes[i].static_threads,
00523                               lanes[i].dynamic_threads,
00524                               dynamic_thread_idle_timeout
00525                              ));
00526 }

TAO_Thread_Pool::~TAO_Thread_Pool void   ) 
 

Destructor.

Definition at line 540 of file Thread_Pool.cpp.

References lanes_, and number_of_lanes_.

00541 {
00542   // Delete all the lanes.
00543   for (CORBA::ULong i = 0;
00544        i != this->number_of_lanes_;
00545        ++i)
00546     delete this->lanes_[i];
00547 
00548   delete[] this->lanes_;
00549 }


Member Function Documentation

ACE_INLINE CORBA::Boolean TAO_Thread_Pool::allow_borrowing void   )  const
 

Definition at line 100 of file Thread_Pool.inl.

References allow_borrowing_.

00101 {
00102   return this->allow_borrowing_;
00103 }

ACE_INLINE CORBA::Boolean TAO_Thread_Pool::allow_request_buffering void   )  const
 

Definition at line 107 of file Thread_Pool.inl.

References allow_request_buffering_.

00108 {
00109   return this->allow_request_buffering_;
00110 }

int TAO_Thread_Pool::create_static_threads void   ) 
 

Create the static threads - only called once.

Definition at line 611 of file Thread_Pool.cpp.

References TAO_Thread_Lane::create_static_threads(), lanes_, and number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::create_threadpool_helper().

00612 {
00613   for (CORBA::ULong i = 0;
00614        i != this->number_of_lanes_;
00615        ++i)
00616     {
00617       // Ask each lane to create its set of static threads.
00618       int result = this->lanes_[i]->create_static_threads ();
00619 
00620       // Return on failure.
00621       if (result != 0)
00622         return result;
00623     }
00624 
00625   // Success.
00626   return 0;
00627 }

void TAO_Thread_Pool::finalize void   ) 
 

Finalize the resources.

Definition at line 552 of file Thread_Pool.cpp.

References TAO_Thread_Lane::finalize(), lanes_, and number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::create_threadpool_helper(), and TAO_Thread_Pool_Manager::destroy_threadpool().

00553 {
00554   // Finalize all the lanes.
00555   for (CORBA::ULong i = 0;
00556        i != this->number_of_lanes_;
00557        ++i)
00558     this->lanes_[i]->finalize ();
00559 }

ACE_INLINE CORBA::ULong TAO_Thread_Pool::id void   )  const
 

Definition at line 86 of file Thread_Pool.inl.

00087 {
00088   return this->id_;
00089 }

int TAO_Thread_Pool::is_collocated const TAO_MProfile mprofile  ) 
 

Does mprofile belong to us?

Definition at line 593 of file Thread_Pool.cpp.

References TAO_Thread_Lane::is_collocated(), lanes_, and number_of_lanes_.

00594 {
00595   // Finalize all the lanes.
00596   for (CORBA::ULong i = 0;
00597        i != this->number_of_lanes_;
00598        ++i)
00599     {
00600       int result =
00601         this->lanes_[i]->is_collocated (mprofile);
00602 
00603       if (result)
00604         return result;
00605     }
00606 
00607   return 0;
00608 }

ACE_INLINE TAO_Thread_Lane ** TAO_Thread_Pool::lanes void   ) 
 

Definition at line 128 of file Thread_Pool.inl.

References lanes_.

00129 {
00130   return this->lanes_;
00131 }

ACE_INLINE TAO_Thread_Pool_Manager & TAO_Thread_Pool::manager void   )  const
 

Definition at line 79 of file Thread_Pool.inl.

References manager_.

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().

00080 {
00081   return this->manager_;
00082 }

ACE_INLINE CORBA::ULong TAO_Thread_Pool::max_buffered_requests void   )  const
 

Definition at line 114 of file Thread_Pool.inl.

References max_buffered_requests_.

00115 {
00116   return this->max_buffered_requests_;
00117 }

ACE_INLINE CORBA::ULong TAO_Thread_Pool::max_request_buffer_size void   )  const
 

Definition at line 121 of file Thread_Pool.inl.

References max_request_buffer_size_.

00122 {
00123   return this->max_request_buffer_size_;
00124 }

ACE_INLINE CORBA::ULong TAO_Thread_Pool::number_of_lanes void   )  const
 

Definition at line 135 of file Thread_Pool.inl.

References number_of_lanes_.

00136 {
00137   return this->number_of_lanes_;
00138 }

void TAO_Thread_Pool::open void   ) 
 

Open the pool.

Definition at line 529 of file Thread_Pool.cpp.

References lanes_, number_of_lanes_, and TAO_Thread_Lane::open().

Referenced by TAO_Thread_Pool_Manager::create_threadpool_helper().

00530 {
00531   // Open all the lanes.
00532   for (CORBA::ULong i = 0;
00533        i != this->number_of_lanes_;
00534        ++i)
00535     {
00536       this->lanes_[i]->open ();
00537     }
00538 }

void TAO_Thread_Pool::shutdown_reactor void   ) 
 

Shutdown the reactor.

Definition at line 562 of file Thread_Pool.cpp.

References lanes_, number_of_lanes_, and TAO_Thread_Lane::shutdown_reactor().

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00563 {
00564   // Finalize all the lanes.
00565   for (CORBA::ULong i = 0;
00566        i != this->number_of_lanes_;
00567        ++i)
00568     this->lanes_[i]->shutdown_reactor ();
00569 }

void TAO_Thread_Pool::shutting_down void   ) 
 

Mark this thread pool that we are shutting down.

Definition at line 572 of file Thread_Pool.cpp.

References lanes_, number_of_lanes_, and TAO_Thread_Lane::shutting_down().

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00573 {
00574   // Finalize all the lanes.
00575   for (CORBA::ULong i = 0;
00576        i != this->number_of_lanes_;
00577        ++i)
00578     this->lanes_[i]->shutting_down ();
00579 }

ACE_INLINE CORBA::ULong TAO_Thread_Pool::stack_size void   )  const
 

Definition at line 93 of file Thread_Pool.inl.

Referenced by TAO_Thread_Lane::create_threads_i().

00094 {
00095   return this->stack_size_;
00096 }

void TAO_Thread_Pool::wait void   ) 
 

Wait for threads to exit.

Definition at line 583 of file Thread_Pool.cpp.

References lanes_, number_of_lanes_, and TAO_Thread_Lane::wait().

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00584 {
00585   // Finalize all the lanes.
00586   for (CORBA::ULong i = 0;
00587        i != this->number_of_lanes_;
00588        ++i)
00589     this->lanes_[i]->wait ();
00590 }

ACE_INLINE bool TAO_Thread_Pool::with_lanes void   )  const
 

Check if this thread pool has (explicit) lanes.

Definition at line 72 of file Thread_Pool.inl.

References with_lanes_.

00073 {
00074   return this->with_lanes_;
00075 }


Member Data Documentation

CORBA::Boolean TAO_Thread_Pool::allow_borrowing_ [private]
 

Definition at line 331 of file Thread_Pool.h.

Referenced by allow_borrowing().

CORBA::Boolean TAO_Thread_Pool::allow_request_buffering_ [private]
 

Definition at line 332 of file Thread_Pool.h.

Referenced by allow_request_buffering().

ACE_Time_Value const TAO_Thread_Pool::dynamic_thread_idle_timeout_ [private]
 

Definition at line 335 of file Thread_Pool.h.

CORBA::ULong TAO_Thread_Pool::id_ [private]
 

Definition at line 328 of file Thread_Pool.h.

TAO_Thread_Lane** TAO_Thread_Pool::lanes_ [private]
 

Definition at line 337 of file Thread_Pool.h.

Referenced by create_static_threads(), finalize(), is_collocated(), lanes(), open(), shutdown_reactor(), shutting_down(), wait(), and ~TAO_Thread_Pool().

TAO_Thread_Pool_Manager& TAO_Thread_Pool::manager_ [private]
 

Definition at line 327 of file Thread_Pool.h.

Referenced by manager().

CORBA::ULong TAO_Thread_Pool::max_buffered_requests_ [private]
 

Definition at line 333 of file Thread_Pool.h.

Referenced by max_buffered_requests().

CORBA::ULong TAO_Thread_Pool::max_request_buffer_size_ [private]
 

Definition at line 334 of file Thread_Pool.h.

Referenced by max_request_buffer_size().

CORBA::ULong TAO_Thread_Pool::number_of_lanes_ [private]
 

Definition at line 338 of file Thread_Pool.h.

Referenced by create_static_threads(), finalize(), is_collocated(), number_of_lanes(), open(), shutdown_reactor(), shutting_down(), TAO_Thread_Pool(), wait(), and ~TAO_Thread_Pool().

CORBA::ULong TAO_Thread_Pool::stack_size_ [private]
 

Definition at line 330 of file Thread_Pool.h.

bool TAO_Thread_Pool::with_lanes_ [private]
 

Definition at line 339 of file Thread_Pool.h.

Referenced by with_lanes().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:35:11 2008 for TAO_RTCORBA by doxygen 1.3.6