#include <gridthreadpool.hpp>
Classes | |
| class | SynchronizedBlockingQueue |
Public Member Functions | |
| GridThreadPool (unsigned int nthreads) | |
| virtual | ~GridThreadPool () |
| void | execute (TGridThreadPoolTaskPtr &task) |
| size_t | queueSize () const |
| void | waitForEmptyQueue () |
| void | shutdown () |
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.
| GridThreadPool::GridThreadPool | ( | unsigned int | nthreads | ) |
Constructs a thread pool and starts the threads.
| nthreads | Number of threads in a pool. |
| GridThreadPool::~GridThreadPool | ( | ) | [virtual] |
Destroys the thread pool.
shutdown() method is called prior to destruction.
| void GridThreadPool::execute | ( | TGridThreadPoolTaskPtr & | task | ) |
Puts task to a queue for further execution by a pool thread.
| task | A task to execute. |
| 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.
| 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.
| GridThreadPoolIsShutdownException | If thread pool is already shut down. |
1.7.1