sends::thread_pool Class Reference
[Sends Data Classes]

Thread pool base class. More...

#include <thread_pool.hh>

Inheritance diagram for sends::thread_pool:

sends::seda_stage sends::authorize sends::concentrator sends::dump_trans sends::fetch_stage sends::lookup_stage sends::parse_stage sends::template_stage sends::write_stage

List of all members.

Public Types

typedef unsigned int count_type
 Thread count data type.

Public Member Functions

 thread_pool (count_type num)
 Thread pool constructor.
virtual ~thread_pool (void)
 Destructor.
count_type capacity (void) const
 Get the maximum number of threads.
count_type count (void) const
virtual void thread_entry (void)
 Process method.
count_type get_busy (void) const
 Number of busy threads.
count_type get_max_busy (void) const
 Maximum number of busy threads.
void lock (void)
 Lock the thread pool.
void make_threads (void)
 Create threads.
void set_size (count_type N)
 Set number of threads.
count_type size (void) const
void unlock (void)
 Unlock the thread pool.
void wait_empty (void)
 Wait for the end.

Static Public Member Functions

static void * thread_exec (void *tp)
 Thread start method.

Protected Member Functions

count_type busy (void)
 Current thread is busy.
void done (void)
 Current thread is done.
bool test_run (void)


Detailed Description

Thread pool base class.

The thread pool base class contains the API of the thread procedure to be performed by each thread in the pool and status and control information for the pool as a whole, including:

Author:
John Zweizig
Version:
1.0; Last modified January 23, 2008

Member Typedef Documentation

typedef unsigned int sends::thread_pool::count_type

Thread count data type.

Data type used to specify thread counts.


Constructor & Destructor Documentation

sends::thread_pool::thread_pool ( count_type  num  ) 

Thread pool constructor.

Construct a thread pool, specifying the number of threads to be run concurrently. Threads aren't created until the user calls make threads after completing any initialization needed.

Parameters:
num Number of threads to be run concurrently.

virtual sends::thread_pool::~thread_pool ( void   )  [virtual]

Destructor.

Destroy a thread pool.


Member Function Documentation

static void* sends::thread_pool::thread_exec ( void *  tp  )  [static]

Thread start method.

This method is used to start up the thread class.

Parameters:
tp Pointer to the class to be
Returns:
Thread return value.

thread_pool::count_type sends::thread_pool::capacity ( void   )  const [inline]

Get the maximum number of threads.

Get the current maximum number of threads to run concurrently.

Returns:
Number of threads.

thread_pool::count_type sends::thread_pool::count ( void   )  const [inline]

Return the number of events the threads have processed. This counter is incremented by each transition of a thread to the busy state.

Returns:
Number of processing events.

virtual void sends::thread_pool::thread_entry ( void   )  [virtual]

Process method.

Thread pool processing method.

Reimplemented in sends::seda_stage.

thread_pool::count_type sends::thread_pool::get_busy ( void   )  const [inline]

Number of busy threads.

Number of threads in the busy state.

Returns:
Number of busy threads.

thread_pool::count_type sends::thread_pool::get_max_busy ( void   )  const [inline]

Maximum number of busy threads.

High water mark for threads in the busy state.

Returns:
Maximum number of busy threads.

void sends::thread_pool::lock ( void   ) 

Lock the thread pool.

Lock the thread pool status information for modification.

void sends::thread_pool::make_threads ( void   ) 

Create threads.

Create as many threads as necessary to bring the current number to max_threads.

void sends::thread_pool::set_size ( count_type  N  ) 

Set number of threads.

Set the maximum number of threads.

Parameters:
N Number of threads.

thread_pool::count_type sends::thread_pool::size ( void   )  const [inline]

Get the current number of running threads.

void sends::thread_pool::unlock ( void   ) 

Unlock the thread pool.

Unlock the thread pool status and control information.

void sends::thread_pool::wait_empty ( void   ) 

Wait for the end.

Wait for the thread pool to empty out.

count_type sends::thread_pool::busy ( void   )  [protected]

Current thread is busy.

Indicate the the current thread is busy. The busy count and use count are incremented.

Returns:
Value of the use count before starting this thread.

void sends::thread_pool::done ( void   )  [protected]

Current thread is done.

Indicate the the current thread has finished. The busy count is decremented.

bool sends::thread_pool::test_run ( void   )  [protected]

test whether the thread is to continue running. Note that the thread must test its run state periodically and terminate immediately if the return value is false.

Returns:
true if thread to continue.


The documentation for this class was generated from the following file:

Generated on Tue Jun 10 12:18:12 2008 for SENDS by  doxygen 1.5.5