Main Page Namespace List Class Hierarchy Compound List Compound Members

# ZThread::Executor Class Reference

`#include <Executor.h>`

Inheritance diagram for ZThread::Executor::

List of all members.

## Public Methods
virtual | ~Executor () throw ()
virtual void | execute (Runnable *task)=0 throw (Synchronization_Exception)
virtual void | cancel ()=0 throw (Synchronization_Exception)
virtual void | join ()=0 throw (Synchronization_Exception)
virtual bool | available ()=0 throw (Synchronization_Exception)
virtual unsigned int | threadCount ()=0 throw (Synchronization_Exception)

## Detailed Description

Date:
  03-10-2001

Author:
  Eric Crahen

Version:
  1.3.0

This interface defines the basic outline needed to implement a LWP (light-weigh-process) execution mechanism.

An executor allows the efficent execution of a number of small unrelated 'Runnable' tasks, or LWP's without the over head of a large number of syncronization controls needed in a thread per task solution.

The executor itself contains heavy wieght syncrhonization controls to do this, but it will not need new ones for each additional task. This overcomes resource problems thread-per-task designs must face

In general, executors queue tasks for execution by another thread or by a pool of threads. The queueing of task allows for a good deal of control over the order of execution.

## Constructor & Destructor Documentation

~Executor ( | ) throw ()`[inline, virtual]`

| Destroy Executor object

## Member Function Documentation

bool available ( | ) throw (Synchronization_Exception)`[pure virtual]`

  | Block until this executor has become available to run new tasks. This does not garuntee that another thread won't have submitted a task before some action is taken in response to this. However, it is useful as a general hueristic Returns: bool Exceptions:
  InterruptedException |
Reimplemented in ZThread::AbstractExecutor, ZThread::PoolExecutor, and ZThread::SyncExecutor.

void cancel ( | ) throw (Synchronization_Exception)`[pure virtual]`

  | Stop the execution of additonal tasks by this executor. After this method has be invoked then the Executor will completed when the last task it was previously assigned is completed. Exceptions:
  InterruptedException |
Postcondition: the executor no longer accepts new tasks. At this point the executor has a limited lifetime and is safe to join Reimplemented from ZThread::Cancelable. Reimplemented in ZThread::AbstractExecutor, and ZThread::SyncExecutor.

void execute ( | Runnable * task ) throw (Synchronization_Exception)`[pure virtual]`

  | Enqueue another task for execution. Parameters:
  Runnable | * task - task to execute NOTE: this bestows ownership of the task upon the executor and so the executor will be responsible for deleting task items. You should take this into account when submitting tasks
  Exceptions:
  InterruptedException |
  Precondition: The executor must not be canceled. A canceled executor will ignore execute() requests. Postcondition: The given task will be executed as soon as possible by the executor Parameters:
  task |
Reimplemented in ZThread::AsyncExecutor, ZThread::PoolExecutor, and ZThread::SyncExecutor.

void join ( | ) throw (Synchronization_Exception)`[pure virtual]`

  | Wait for this Executor to complete. The calling thread is blocked until the last task has been completed by this executor or until the calling thread has been interrupted. Exceptions:
  InterruptedException |
Reimplemented in ZThread::AsyncExecutor, ZThread::PoolExecutor, and ZThread::SyncExecutor.

unsigned int threadCount ( | ) throw (Synchronization_Exception)`[pure virtual]`

  | Count of active threads operation on behalf of this executor This does not garuntee that another thread won't have submitted a task that changes the number of executing threads before some action is taken in response to this. However, it is useful as a general hueristic Returns: unsigned int Exceptions:
  InterruptedException |
Reimplemented in ZThread::AsyncExecutor, ZThread::PoolExecutor, and ZThread::SyncExecutor.

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

- Executor.h