ZThread::PoolExecutor Class Reference

#include <PoolExecutor.h>

Inheritance diagram for ZThread::PoolExecutor:

ZThread::Executor ZThread::Cancelable ZThread::Waitable ZThread::NonCopyable 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,

See also:
Executor.


Constructor & Destructor Documentation

ZThread::PoolExecutor::PoolExecutor ( size_t  n  ) 

Create a PoolExecutor

Parameters:
n number of threads to service tasks with

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


Member Function Documentation

void ZThread::PoolExecutor::cancel (  )  [virtual]

See also:
Cancelable::cancel()

Implements ZThread::Cancelable.

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.

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

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 ZThread::Executor.

bool ZThread::PoolExecutor::isCanceled (  )  [virtual]

See also:
Cancelable::isCanceled()

Implements ZThread::Cancelable.

size_t ZThread::PoolExecutor::size (  ) 

Get the current number of threads being used to execute submitted tasks.

Returns:
n number of worker threads.

void ZThread::PoolExecutor::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.

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.

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 ZThread::Waitable.

void ZThread::PoolExecutor::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 ZThread::Waitable.


The documentation for this class was generated from the following files:
Generated on Wed Aug 30 03:27:48 2006 for SWG EMU by  doxygen 1.4.7