Main Page   Namespace List   Class Hierarchy   Compound List   Compound Members  

ZThread::SyncExecutor Class Template Reference

#include <SyncExecutor.h>

Inheritance diagram for ZThread::SyncExecutor::

ZThread::Executor ZThread::Cancelable List of all members.

Public Methods

 SyncExecutor ()
virtual ~SyncExecutor () throw ()
virtual void execute (Runnable *task) throw (Synchronization_Exception)
virtual void cancel () throw (Synchronization_Exception)
virtual bool isCanceled () throw (Synchronization_Exception)
virtual void join () throw (Synchronization_Exception)
virtual bool available () throw (Synchronization_Exception)
virtual unsigned int threadCount () throw (Synchronization_Exception)

Protected Types

typedef L LOCK
 Typedef.


Protected Attributes

LOCK _lock
 Serialize access.

bool _canceled
 Cancellation flag.


Detailed Description

template<class L = Mutex> class ZThread::SyncExecutor

Date:
09-21-2000
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 efficient execution of a number of small unrelated 'Runnable' tasks, or LWP's without the over head of a large number of synchronization controls needed in a thread per task solution.

The executor itself contains heavy weight synchronization 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 queuing of task allows for a good deal of control over the order of execution.

SynchExecutors will never consume tasks. Thier behavior makes it very easy to use shared task objects, or task objects that have been automatically allocated.


Constructor & Destructor Documentation

SyncExecutor ( ) [inline]
 

Create a new SyncExecutor

~SyncExecutor ( ) throw () [inline, virtual]
 

Destroy this Executor


Member Function Documentation

bool available ( ) throw (Synchronization_Exception) [inline, virtual]
 

Block until this executor has become available to run new tasks.

This does not guarantee 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 heuristic

Returns:
boolean
Exceptions:
InterruptedException  

Reimplemented from ZThread::Executor.

void cancel ( ) throw (Synchronization_Exception) [inline, virtual]
 

Stop the execution of additional 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::Executor.

void execute ( Runnable * task ) throw (Synchronization_Exception) [inline, virtual]
 

Enqueue another task for execution.

Parameters:
Runnable   task - task to execute
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 from ZThread::Executor.

bool isCanceled ( ) throw (Synchronization_Exception) [inline, virtual]
 

Check the cancelation status of this Executor

Returns:
bool - Executor canceled
See also:
Cancelable::isCanceled()

Reimplemented from ZThread::Cancelable.

void join ( ) throw (Synchronization_Exception) [inline, 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 from ZThread::Executor.

unsigned int threadCount ( ) throw (Synchronization_Exception) [inline, virtual]
 

Count of active threads operation on behalf of this executor

This does not guarantee 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 heuristic

Returns:
unsigned int
Exceptions:
InterruptedException  

Reimplemented from ZThread::Executor.


The documentation for this class was generated from the following file:
Generated at Fri Aug 31 09:08:02 2001 for ZThread by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001