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 ()
 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 258 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 461 of file Thread_Pool.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_THROW, lanes_, number_of_lanes_, and TAO_Thread_Lane.

00472   : manager_ (manager),
00473     id_ (id),
00474     stack_size_ (stack_size),
00475     allow_borrowing_ (0),
00476     allow_request_buffering_ (allow_request_buffering),
00477     max_buffered_requests_ (max_buffered_requests),
00478     max_request_buffer_size_ (max_request_buffer_size),
00479     dynamic_thread_idle_timeout_ (dynamic_thread_idle_timeout),
00480     lanes_ (0),
00481     number_of_lanes_ (1),
00482     with_lanes_ (false)
00483 {
00484   // No support for buffering.
00485   if (allow_request_buffering)
00486     ACE_THROW (CORBA::NO_IMPLEMENT ());
00487 
00488   // Create one lane.
00489   this->lanes_ = new TAO_Thread_Lane *[this->number_of_lanes_];
00490   this->lanes_[0] =
00491     new TAO_Thread_Lane (*this,
00492                          0,
00493                          default_priority,
00494                          static_threads,
00495                          dynamic_threads,
00496                          dynamic_thread_idle_timeout
00497                          ACE_ENV_ARG_PARAMETER);
00498 }

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 500 of file Thread_Pool.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_THROW, lanes_, number_of_lanes_, and TAO_Thread_Lane.

00510   : manager_ (manager),
00511     id_ (id),
00512     stack_size_ (stack_size),
00513     allow_borrowing_ (allow_borrowing),
00514     allow_request_buffering_ (allow_request_buffering),
00515     max_buffered_requests_ (max_buffered_requests),
00516     max_request_buffer_size_ (max_request_buffer_size),
00517     dynamic_thread_idle_timeout_ (dynamic_thread_idle_timeout),
00518     lanes_ (0),
00519     number_of_lanes_ (lanes.length ()),
00520     with_lanes_ (true)
00521 {
00522   // No support for buffering or borrowing.
00523   if (allow_borrowing ||
00524       allow_request_buffering)
00525     ACE_THROW (CORBA::NO_IMPLEMENT ());
00526 
00527   // Create multiple lane.
00528   this->lanes_ = new TAO_Thread_Lane *[this->number_of_lanes_];
00529   for (CORBA::ULong i = 0;
00530        i != this->number_of_lanes_;
00531        ++i)
00532     this->lanes_[i] =
00533       new TAO_Thread_Lane (*this,
00534                            i,
00535                            lanes[i].lane_priority,
00536                            lanes[i].static_threads,
00537                            lanes[i].dynamic_threads,
00538                            dynamic_thread_idle_timeout
00539                            ACE_ENV_ARG_PARAMETER);
00540 }

TAO_Thread_Pool::~TAO_Thread_Pool void   ) 
 

Destructor.

Definition at line 555 of file Thread_Pool.cpp.

References lanes_, and number_of_lanes_.

00556 {
00557   // Delete all the lanes.
00558   for (CORBA::ULong i = 0;
00559        i != this->number_of_lanes_;
00560        ++i)
00561     delete this->lanes_[i];
00562 
00563   delete[] this->lanes_;
00564 }


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 626 of file Thread_Pool.cpp.

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

00627 {
00628   for (CORBA::ULong i = 0;
00629        i != this->number_of_lanes_;
00630        ++i)
00631     {
00632       // Ask each lane to create its set of static threads.
00633       int result = this->lanes_[i]->create_static_threads ();
00634 
00635       // Return on failure.
00636       if (result != 0)
00637         return result;
00638     }
00639 
00640   // Success.
00641   return 0;
00642 }

void TAO_Thread_Pool::finalize void   ) 
 

Finalize the resources.

Definition at line 567 of file Thread_Pool.cpp.

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

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00568 {
00569   // Finalize all the lanes.
00570   for (CORBA::ULong i = 0;
00571        i != this->number_of_lanes_;
00572        ++i)
00573     this->lanes_[i]->finalize ();
00574 }

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 608 of file Thread_Pool.cpp.

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

00609 {
00610   // Finalize all the lanes.
00611   for (CORBA::ULong i = 0;
00612        i != this->number_of_lanes_;
00613        ++i)
00614     {
00615       int result =
00616         this->lanes_[i]->is_collocated (mprofile);
00617 
00618       if (result)
00619         return result;
00620     }
00621 
00622   return 0;
00623 }

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  ) 
 

Open the pool.

Definition at line 543 of file Thread_Pool.cpp.

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

00544 {
00545   // Open all the lanes.
00546   for (CORBA::ULong i = 0;
00547        i != this->number_of_lanes_;
00548        ++i)
00549     {
00550       this->lanes_[i]->open (ACE_ENV_SINGLE_ARG_PARAMETER);
00551       ACE_CHECK;
00552     }
00553 }

void TAO_Thread_Pool::shutdown_reactor void   ) 
 

Shutdown the reactor.

Definition at line 577 of file Thread_Pool.cpp.

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

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00578 {
00579   // Finalize all the lanes.
00580   for (CORBA::ULong i = 0;
00581        i != this->number_of_lanes_;
00582        ++i)
00583     this->lanes_[i]->shutdown_reactor ();
00584 }

void TAO_Thread_Pool::shutting_down void   ) 
 

Mark this thread pool that we are shutting down.

Definition at line 587 of file Thread_Pool.cpp.

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

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00588 {
00589   // Finalize all the lanes.
00590   for (CORBA::ULong i = 0;
00591        i != this->number_of_lanes_;
00592        ++i)
00593     this->lanes_[i]->shutting_down ();
00594 }

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 598 of file Thread_Pool.cpp.

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

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00599 {
00600   // Finalize all the lanes.
00601   for (CORBA::ULong i = 0;
00602        i != this->number_of_lanes_;
00603        ++i)
00604     this->lanes_[i]->wait ();
00605 }

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 337 of file Thread_Pool.h.

Referenced by allow_borrowing().

CORBA::Boolean TAO_Thread_Pool::allow_request_buffering_ [private]
 

Definition at line 338 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 341 of file Thread_Pool.h.

CORBA::ULong TAO_Thread_Pool::id_ [private]
 

Definition at line 334 of file Thread_Pool.h.

TAO_Thread_Lane** TAO_Thread_Pool::lanes_ [private]
 

Definition at line 343 of file Thread_Pool.h.

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

TAO_Thread_Pool_Manager& TAO_Thread_Pool::manager_ [private]
 

Definition at line 333 of file Thread_Pool.h.

Referenced by manager().

CORBA::ULong TAO_Thread_Pool::max_buffered_requests_ [private]
 

Definition at line 339 of file Thread_Pool.h.

Referenced by max_buffered_requests().

CORBA::ULong TAO_Thread_Pool::max_request_buffer_size_ [private]
 

Definition at line 340 of file Thread_Pool.h.

Referenced by max_request_buffer_size().

CORBA::ULong TAO_Thread_Pool::number_of_lanes_ [private]
 

Definition at line 344 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 336 of file Thread_Pool.h.

bool TAO_Thread_Pool::with_lanes_ [private]
 

Definition at line 345 of file Thread_Pool.h.

Referenced by with_lanes().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:00:08 2006 for TAO_RTCORBA by doxygen 1.3.6