#include <PoolExecutor.h>
Inheritance diagram for ZThread::PoolExecutor:
Public Member Functions | |
PoolExecutor (size_t n) | |
virtual | ~PoolExecutor () |
Destroy a PoolExecutor. | |
virtual void | interrupt () |
void | size (size_t n) |
size_t | size () |
virtual void | execute (const Task &task) |
virtual void | cancel () |
virtual bool | isCanceled () |
virtual void | wait () |
virtual bool | wait (unsigned long timeout) |
ZThread::PoolExecutor::PoolExecutor | ( | size_t | n | ) |
ZThread::PoolExecutor::~PoolExecutor | ( | ) | [virtual] |
Destroy a PoolExecutor.
If the shutdown task for this executor has not already been selected to run, then run it locally
void ZThread::PoolExecutor::cancel | ( | ) | [virtual] |
void ZThread::PoolExecutor::execute | ( | const Task & | task | ) | [virtual] |
Submit a task to this Executor.
This will not block the calling thread very long. The submitted task will be executed at some later point by another thread.
task | Task to be run by a thread managed by this executor |
Cancellation_Exception | thrown if the Executor was canceled prior to the invocation of this function. |
Implements ZThread::Executor.
void ZThread::PoolExecutor::interrupt | ( | ) | [virtual] |
Invoking this function causes each task that had been submitted prior to this function to be interrupted. Tasks submitted after the invocation of this function are unaffected.
Any thread already executing a task which was submitted prior to the invocation of this function will be interrupted.
Implements ZThread::Executor.
bool ZThread::PoolExecutor::isCanceled | ( | ) | [virtual] |
size_t ZThread::PoolExecutor::size | ( | ) |
Get the current number of threads being used to execute submitted tasks.
void ZThread::PoolExecutor::size | ( | size_t | n | ) |
Alter the number of threads being used to execute submitted tasks.
n | number of worker threads. |
InvalidOp_Exception | thrown if the new number of threads n is less than 1. |
bool ZThread::PoolExecutor::wait | ( | unsigned long | timeout | ) | [virtual] |
Block the calling thread until all tasks submitted prior to this invocation complete or until the calling thread is interrupted.
timeout | maximum amount of time, in milliseconds, to wait for the currently submitted set of Tasks to complete. |
Interrupted_Exception | thrown if the calling thread is interrupted before the set of tasks being wait for can complete. |
Implements ZThread::Waitable.
void ZThread::PoolExecutor::wait | ( | ) | [virtual] |
Block the calling thread until all tasks submitted prior to this invocation complete.
Interrupted_Exception | thrown if the calling thread is interrupted before the set of tasks being wait for can complete. |
Implements ZThread::Waitable.