Main Page Namespace List Class Hierarchy Compound List Compound Members

# ZThread::Worker Class Template Reference

`#include <Worker.h>`

Inheritance diagram for ZThread::Worker::

List of all members.

## Public Methods
| Worker (TaskQueue q) throw (Synchronization_Exception)
virtual | ~Worker () throw ()
virtual void | kill () throw (Synchronization_Exception)
virtual bool | isKilled () throw ()
virtual void | run () throw ()
## Protected Types
typedef Queue<Runnable*>* | TaskQueue
| Typedef.
## Protected Methods
void | finished (Runnable *)
## Protected Attributes
TaskQueue | _taskQueue
| TaskQueue.
bool | _canceled
| Cancel flag.

## Detailed Description

### template<bool CONSUMING = true> class ZThread::Worker

Date:
  04-28-2001

Author:
  Eric Crahen

Version:
  1.4.1

A template for generating Worker threads that are designed for work in Executors. They can be useful anywhere a group of worker threads that feed on a shared TaskQueue is needed.

In addition the template provides specializations for task consuming or task reading workers. A consuming worker destroys tasks it has executed, otherwise it simply executes the task and makes no attempt to destroy that task.

## Constructor & Destructor Documentation

Worker ( | TaskQueue q ) throw (Synchronization_Exception)`[inline]`

  | Create an AsyncWorker associated with a TaskQueue Parameters:
  q |

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

| Destroy the AsyncWorker

## Member Function Documentation

void finished ( | Runnable * task )`[inline, protected]`

  | As each task is completed, it is passed into this method to properly deal with its completion. This function will destroy the taks objects of a consuming worker, otherwise it has no effect. Postcondition: The task passed to this method will be delete'd or not depending on the nature of this Worker Parameters:
  task |

bool isKilled ( | ) throw ()`[inline, virtual]`

| Check the internal flag to see if this Worker has been killed; or marked as no longer usable Returns: bool - cancelation status Reimplemented from ZThread::Thread.

void kill ( | ) throw (Synchronization_Exception)`[inline, virtual]`

| Mark the thread as killed w/o actuallying kill()ing it and therefore w/o interefering with any task already executing Reimplemented from ZThread::Thread.

void run ( | ) throw ()`[inline, virtual]`

| Tasks will be executed and removed from the queue. Wether or not those tasks are deleted depends on the template parameter. Reimplemented from ZThread::Thread.

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

- Worker.h