Classes | Public Member Functions

GridThreadPool Class Reference

#include <gridthreadpool.hpp>

List of all members.

Classes

class  SynchronizedBlockingQueue

Public Member Functions

 GridThreadPool (unsigned int nthreads)
virtual ~GridThreadPool ()
void execute (TGridThreadPoolTaskPtr &task)
size_t queueSize () const
void waitForEmptyQueue ()
void shutdown ()

Detailed Description

A thread pool that is capable of performing tasks over a number of pre-launched threads.

All tasks are put into a queue and taken out by the pool threads.

The queue size is unbounded.


Constructor & Destructor Documentation

GridThreadPool::GridThreadPool ( unsigned int  nthreads  ) 

Constructs a thread pool and starts the threads.

Parameters:
nthreads Number of threads in a pool.
GridThreadPool::~GridThreadPool (  )  [virtual]

Destroys the thread pool.

shutdown() method is called prior to destruction.


Member Function Documentation

void GridThreadPool::execute ( TGridThreadPoolTaskPtr &  task  ) 

Puts task to a queue for further execution by a pool thread.

Parameters:
task A task to execute.
Exceptions:
GridThreadPoolIsShutdownException If thread pool is already shut down.
size_t GridThreadPool::queueSize (  )  const

Returns a current number of tasks in task queue.

void GridThreadPool::shutdown (  ) 

Shuts down this thread pool.

Upon completion all pool threads are stopped, and the pool cannot be used anymore.

This method may be called any number of times, and is called automatically from destructor.

Exceptions:
GridThreadPoolIsShutdownException If thread pool is already shut down.
void GridThreadPool::waitForEmptyQueue (  ) 

Blocks current thread until task queue is empty (all tasks are executed).

Made for testing purposes.

Exceptions:
GridThreadPoolIsShutdownException If thread pool is already shut down.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends