ZThread::ConcurrentExecutor Class Reference

#include <ConcurrentExecutor.h>

Inheritance diagram for ZThread::ConcurrentExecutor:

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

Public Member Functions

 ConcurrentExecutor ()
 Create a ConcurrentExecutor.
virtual void interrupt ()
virtual void execute (const 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:36:11-0400>
Version:
2.3.0
A ConcurrentExecutor spawns a single thread to service a series of Tasks.

See also:
PoolExecutor.


Member Function Documentation

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

See also:
Cancelable::cancel()

Implements ZThread::Cancelable.

void ZThread::ConcurrentExecutor::execute ( const Task  )  [virtual]

Submit a Task to this Executor. This will not block the current thread for very long. The task will be enqueued internally and eventually run in the context of the single thread driving all the Tasks submitted to this Executor.

Exceptions:
Cancellation_Exception thrown if this Executor has been canceled. The Task being submitted will not be executed by this Executor.
Synchronization_Exception thrown only in the event of an error in the implementation of the library.
See also:
Executor::execute(const Task&)

Implements ZThread::Executor.

void ZThread::ConcurrentExecutor::interrupt (  )  [virtual]

Interrupting a ConcurrentExecutor will cause the thread running the tasks to be be interrupted once during the execution of each task that has been submitted at the time this function is called.

Tasks that are submitted after this function is called will not be interrupt()ed; unless this function is invoked again().

 void aFunction() {

   ConcurrentExecutor executor;

   // Submit p Tasks
   for(size_t n = 0; n < p; n++)
     executor.execute(new aRunnable);

   // Tasks [m, p) may be interrupted, where m is the first task that has 
   // not completed at the time the interrupt() is invoked. 
   executor.interrupt();

   // Submit (q - p) Tasks
   for(size_t n = p; n < q; n++)
     executor.execute(new Chore);
 
   // Tasks [p, q) are not interrupted 

 }

Implements ZThread::Executor.

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

See also:
Cancelable::isCanceled()

Implements ZThread::Cancelable.

bool ZThread::ConcurrentExecutor::wait ( unsigned long  timeout  )  [virtual]

See also:
PoolExecutor::wait(unsigned long timeout)

Implements ZThread::Waitable.

void ZThread::ConcurrentExecutor::wait (  )  [virtual]

See also:
PoolExecutor::wait()

Implements ZThread::Waitable.


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