#include <PoolExecutor.h>

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) |
virtual void | interrupt ()=0 |
virtual void | execute (const Task &task)=0 |
![]() | |
virtual | ~Cancelable () |
Destroy a Cancelable object. | |
virtual void | cancel ()=0 |
virtual bool | isCanceled ()=0 |
![]() | |
virtual | ~Waitable () |
Destroy a Waitable object. | |
virtual void | wait ()=0 |
virtual bool | wait (unsigned long timeout)=0 |
Detailed Description
- Date
- <2003-07-16T22:41:07-0400>
- Version
- 2.3.0
A PoolExecutor spawns a set of threads that are used to run tasks that are submitted in parallel. A PoolExecutor supports the following optional operations,
- cancel()ing a PoolExecutor will cause it to stop accepting new tasks.
- interrupt()ing a PoolExecutor will cause the any thread running a task which was submitted prior to the invocation of this function to be interrupted during the execution of that task.
- wait()ing on a PoolExecutor will block the calling thread until all tasks that were submitted prior to the invocation of this function have completed.
- See also
- Executor.
Constructor & Destructor Documentation
◆ PoolExecutor()
PoolExecutor | ( | size_t | n | ) |
Create a PoolExecutor
- Parameters
-
n number of threads to service tasks with
Member Function Documentation
◆ cancel()
|
virtual |
- See also
- Cancelable::cancel()
Implements Cancelable.
◆ execute()
|
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.
- Parameters
-
task Task to be run by a thread managed by this executor
- Precondition
- The Executor should have been canceled prior to this invocation.
- Postcondition
- The submitted task will be run at some point in the future by this Executor.
- Exceptions
-
Cancellation_Exception thrown if the Executor was canceled prior to the invocation of this function.
Implements Executor.
◆ 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.
- Postcondition
- Any task submitted prior to the invocation of this function will be run in the context of an interrupted thread.
-
Any thread already executing a task which was submitted prior to the invocation of this function will be interrupted.
Implements Executor.
◆ isCanceled()
|
virtual |
- See also
- Cancelable::isCanceled()
Implements Cancelable.
◆ size() [1/2]
size_t size | ( | ) |
Get the current number of threads being used to execute submitted tasks.
- Returns
- n number of worker threads.
◆ size() [2/2]
void size | ( | size_t | n | ) |
Alter the number of threads being used to execute submitted tasks.
- Parameters
-
n number of worker threads.
- Precondition
- n must be greater than 0.
- Postcondition
- n threads will be executing tasks submitted to this executor.
- Exceptions
-
InvalidOp_Exception thrown if the new number of threads n is less than 1.
◆ wait() [1/2]
|
virtual |
Block the calling thread until all tasks submitted prior to this invocation complete.
- Exceptions
-
Interrupted_Exception thrown if the calling thread is interrupted before the set of tasks being wait for can complete.
- See also
- Waitable::wait()
Implements Waitable.
◆ wait() [2/2]
|
virtual |
Block the calling thread until all tasks submitted prior to this invocation complete or until the calling thread is interrupted.
- Parameters
-
timeout maximum amount of time, in milliseconds, to wait for the currently submitted set of Tasks to complete.
- Exceptions
-
Interrupted_Exception thrown if the calling thread is interrupted before the set of tasks being wait for can complete.
- Returns
- true if the set of tasks being wait for complete before timeout milliseconds elapse.
- false otherwise.
Implements Waitable.
The documentation for this class was generated from the following file:
- PoolExecutor.h