If you can read this text, it means you are not experiencing this website at its best. This website is designed for used with a standards-compliant browser.
Current version: 2.3.1
ZThreads
A platform-independent, multi-threading and synchronization library for C++
Home Documentation Downloads CVS Contact

# PoolExecutor Class Reference

`#include <PoolExecutor.h>`

Inheritance diagram for PoolExecutor:

List of all members.

## 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)

## Detailed Description

Author:
  Eric Crahen <http://www.code-foo.com>

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 | ( | size_t | n | ) |

  | Create a PoolExecutor Parameters:
  n | number of threads to service tasks with

## Member Function Documentation

virtual void cancel | ( |  | ) | `[virtual]`

| See also: Cancelable::cancel() Implements Cancelable.

virtual void 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. 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.
See also: PoolExecutor::cancel() Executor::execute(const Task& task) Implements Executor.

virtual void 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.

virtual bool isCanceled | ( |  | ) | `[virtual]`

| See also: Cancelable::isCanceled() Implements Cancelable.

size_t size | ( |  | ) |

| Get the current number of threads being used to execute submitted tasks. Returns: n number of worker threads.

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.

virtual bool 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. 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. See also: Waitable::wait(unsigned long timeout) Implements Waitable.

virtual void wait | ( |  | ) | `[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.

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

- PoolExecutor.h