Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members  

Worker Class Template Reference

#include <Worker.h>

Inheritance diagram for Worker:

Thread Runnable NonCopyable 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 Q * TaskQueue
 Typedef.


Protected Methods

void finished (Runnable *task)

Protected Attributes

TaskQueue _taskQueue
 TaskQueue.

bool _canceled
 Cancel flag.


Detailed Description

template<bool CONSUMING = true, class Q = Queue<Runnable*>>
class ZThread::Worker< CONSUMING, Q >

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-05-28T20:21:45-0400>
Version:
2.1.0
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

virtual ~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

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

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

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


The documentation for this class was generated from the following file:
Generated on Fri May 31 14:08:47 2002 for ZThread by doxygen1.2.15