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, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time)
 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, TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan lifespan, ACE_Time_Value const &dynamic_thread_time)
 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_
TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan
const 
lifespan_
ACE_Time_Value const dynamic_thread_time_
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,
TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan  lifespan,
ACE_Time_Value const &  dynamic_thread_time 
)

Constructor (for pools without lanes).

Definition at line 482 of file Thread_Pool.cpp.

References ACE_NEW.

00493   : manager_ (manager),
00494     id_ (id),
00495     stack_size_ (stack_size),
00496     allow_borrowing_ (0),
00497     allow_request_buffering_ (allow_request_buffering),
00498     max_buffered_requests_ (max_buffered_requests),
00499     max_request_buffer_size_ (max_request_buffer_size),
00500     lifespan_ (lifespan),
00501     dynamic_thread_time_ (dynamic_thread_time),
00502     lanes_ (0),
00503     number_of_lanes_ (1),
00504     with_lanes_ (false)
00505 {
00506   // No support for buffering.
00507   if (allow_request_buffering)
00508     throw ::CORBA::NO_IMPLEMENT ();
00509 
00510   // Create one lane.
00511   ACE_NEW (this->lanes_,
00512            TAO_Thread_Lane *[this->number_of_lanes_]);
00513   ACE_NEW (this->lanes_[0],
00514            TAO_Thread_Lane (*this,
00515                             0,
00516                             default_priority,
00517                             static_threads,
00518                             dynamic_threads,
00519                             lifespan,
00520                             dynamic_thread_time
00521                            ));
00522 }

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,
TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan  lifespan,
ACE_Time_Value const &  dynamic_thread_time 
)

Constructor (for pools with lanes).

Definition at line 524 of file Thread_Pool.cpp.

References ACE_NEW, and number_of_lanes_.

00534   : manager_ (manager),
00535     id_ (id),
00536     stack_size_ (stack_size),
00537     allow_borrowing_ (allow_borrowing),
00538     allow_request_buffering_ (allow_request_buffering),
00539     max_buffered_requests_ (max_buffered_requests),
00540     max_request_buffer_size_ (max_request_buffer_size),
00541     lifespan_ (lifespan),
00542     dynamic_thread_time_ (dynamic_thread_time),
00543     lanes_ (0),
00544     number_of_lanes_ (lanes.length ()),
00545     with_lanes_ (true)
00546 {
00547   // No support for buffering or borrowing.
00548   if (allow_borrowing ||
00549       allow_request_buffering)
00550     throw ::CORBA::NO_IMPLEMENT ();
00551 
00552   // Create multiple lane.
00553   ACE_NEW (this->lanes_,
00554            TAO_Thread_Lane *[this->number_of_lanes_]);
00555   for (CORBA::ULong i = 0;
00556        i != this->number_of_lanes_;
00557        ++i)
00558     ACE_NEW (this->lanes_[i],
00559              TAO_Thread_Lane (*this,
00560                               i,
00561                               lanes[i].lane_priority,
00562                               lanes[i].static_threads,
00563                               lanes[i].dynamic_threads,
00564                               lifespan,
00565                               dynamic_thread_time
00566                              ));
00567 }

TAO_Thread_Pool::~TAO_Thread_Pool ( void   ) 

Destructor.

Definition at line 581 of file Thread_Pool.cpp.

References number_of_lanes_.

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


Member Function Documentation

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

Definition at line 107 of file Thread_Pool.inl.

References allow_borrowing_.

00108 {
00109   return this->allow_borrowing_;
00110 }

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

Definition at line 114 of file Thread_Pool.inl.

References allow_request_buffering_.

00115 {
00116   return this->allow_request_buffering_;
00117 }

int TAO_Thread_Pool::create_static_threads ( void   ) 

Create the static threads - only called once.

Definition at line 652 of file Thread_Pool.cpp.

References number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::create_threadpool_helper().

00653 {
00654   for (CORBA::ULong i = 0;
00655        i != this->number_of_lanes_;
00656        ++i)
00657     {
00658       // Ask each lane to create its set of static threads.
00659       int const result = this->lanes_[i]->create_static_threads ();
00660 
00661       // Return on failure.
00662       if (result != 0)
00663         return result;
00664     }
00665 
00666   // Success.
00667   return 0;
00668 }

void TAO_Thread_Pool::finalize ( void   ) 

Finalize the resources.

Definition at line 593 of file Thread_Pool.cpp.

References number_of_lanes_.

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

00594 {
00595   // Finalize all the lanes.
00596   for (CORBA::ULong i = 0;
00597        i != this->number_of_lanes_;
00598        ++i)
00599     this->lanes_[i]->finalize ();
00600 }

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

Definition at line 93 of file Thread_Pool.inl.

References id_.

00094 {
00095   return this->id_;
00096 }

int TAO_Thread_Pool::is_collocated ( const TAO_MProfile mprofile  ) 

Does mprofile belong to us?

Definition at line 634 of file Thread_Pool.cpp.

References number_of_lanes_.

00635 {
00636   // Finalize all the lanes.
00637   for (CORBA::ULong i = 0;
00638        i != this->number_of_lanes_;
00639        ++i)
00640     {
00641       int result =
00642         this->lanes_[i]->is_collocated (mprofile);
00643 
00644       if (result)
00645         return result;
00646     }
00647 
00648   return 0;
00649 }

ACE_INLINE TAO_Thread_Lane ** TAO_Thread_Pool::lanes ( void   ) 

Definition at line 135 of file Thread_Pool.inl.

References lanes_.

00136 {
00137   return this->lanes_;
00138 }

ACE_INLINE TAO_Thread_Pool_Manager & TAO_Thread_Pool::manager ( void   )  const

Definition at line 86 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().

00087 {
00088   return this->manager_;
00089 }

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

Definition at line 121 of file Thread_Pool.inl.

References max_buffered_requests_.

00122 {
00123   return this->max_buffered_requests_;
00124 }

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

Definition at line 128 of file Thread_Pool.inl.

References max_request_buffer_size_.

00129 {
00130   return this->max_request_buffer_size_;
00131 }

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

Definition at line 142 of file Thread_Pool.inl.

References number_of_lanes_.

00143 {
00144   return this->number_of_lanes_;
00145 }

void TAO_Thread_Pool::open ( void   ) 

Open the pool.

Definition at line 570 of file Thread_Pool.cpp.

References number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::create_threadpool_helper().

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

void TAO_Thread_Pool::shutdown_reactor ( void   ) 

Shutdown the reactor.

Definition at line 603 of file Thread_Pool.cpp.

References number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00604 {
00605   // Finalize all the lanes.
00606   for (CORBA::ULong i = 0;
00607        i != this->number_of_lanes_;
00608        ++i)
00609     this->lanes_[i]->shutdown_reactor ();
00610 }

void TAO_Thread_Pool::shutting_down ( void   ) 

Mark this thread pool that we are shutting down.

Definition at line 613 of file Thread_Pool.cpp.

References number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00614 {
00615   // Finalize all the lanes.
00616   for (CORBA::ULong i = 0;
00617        i != this->number_of_lanes_;
00618        ++i)
00619     this->lanes_[i]->shutting_down ();
00620 }

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

Definition at line 100 of file Thread_Pool.inl.

References stack_size_.

00101 {
00102   return this->stack_size_;
00103 }

void TAO_Thread_Pool::wait ( void   ) 

Wait for threads to exit.

Definition at line 624 of file Thread_Pool.cpp.

References number_of_lanes_.

Referenced by TAO_Thread_Pool_Manager::destroy_threadpool().

00625 {
00626   // Finalize all the lanes.
00627   for (CORBA::ULong i = 0;
00628        i != this->number_of_lanes_;
00629        ++i)
00630     this->lanes_[i]->wait ();
00631 }

ACE_INLINE bool TAO_Thread_Pool::with_lanes ( void   )  const

Check if this thread pool has (explicit) lanes.

Definition at line 79 of file Thread_Pool.inl.

References with_lanes_.

00080 {
00081   return this->with_lanes_;
00082 }


Member Data Documentation

CORBA::Boolean TAO_Thread_Pool::allow_borrowing_ [private]

Definition at line 336 of file Thread_Pool.h.

Referenced by allow_borrowing().

CORBA::Boolean TAO_Thread_Pool::allow_request_buffering_ [private]

Definition at line 337 of file Thread_Pool.h.

Referenced by allow_request_buffering().

ACE_Time_Value const TAO_Thread_Pool::dynamic_thread_time_ [private]

Definition at line 341 of file Thread_Pool.h.

CORBA::ULong TAO_Thread_Pool::id_ [private]

Definition at line 333 of file Thread_Pool.h.

Referenced by id().

TAO_Thread_Lane** TAO_Thread_Pool::lanes_ [private]

Definition at line 343 of file Thread_Pool.h.

Referenced by lanes().

TAO_RT_ORBInitializer::TAO_RTCORBA_DT_LifeSpan const TAO_Thread_Pool::lifespan_ [private]

Definition at line 340 of file Thread_Pool.h.

TAO_Thread_Pool_Manager& TAO_Thread_Pool::manager_ [private]

Definition at line 332 of file Thread_Pool.h.

Referenced by manager().

CORBA::ULong TAO_Thread_Pool::max_buffered_requests_ [private]

Definition at line 338 of file Thread_Pool.h.

Referenced by max_buffered_requests().

CORBA::ULong TAO_Thread_Pool::max_request_buffer_size_ [private]

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

Referenced by stack_size().

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 Tue Feb 2 17:43:03 2010 for TAO_RTCORBA by  doxygen 1.4.7