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

Cancelable Class Reference

#include <Cancelable.h>

Inheritance diagram for Cancelable:

CancelableTask Executor Queue Thread ConcurrentExecutor PoolExecutor SynchronousExecutor ThreadedExecutor BlockingQueue BoundedQueue LockedQueue MonitoredQueue List of all members.

Public Methods

virtual ~Cancelable () throw ()
 Destroy a Cancelable object.

virtual void cancel ()=0
virtual bool isCanceled ()=0

Detailed Description

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-06-02T09:13:37-0400>
Version:
2.2.0
The Cancelable interface defines a common method of adding general disable-and-exit semantics to some object. By cancel()ing a Cancelable object, a request is made to disable that object. A simple description of this interface might be that it can be used to define an object that can be elegantly shutdown.

The following text describes the specific meaning of disable-and-exit semantics in more detail.

Disabling

A cancel()ed object may not neccessarily abort it work immediately. Often, it much more elegant for a cancel()ed object to complete handling whatever responsiblies have been assigned to it, but it will not take on any new responsiblity.

Exiting

A cancel()ed must complete its responsibilites as soon as possible. Canceling is not just a request to stop taking on new responsibility, and to complete its current responsibility. Its also a request to complete dealing with its current responsibilites quickly. This should happen in a determinent amount of time and may involve handing that responsibility off to some other object.

The details of these semantics are refined further by specializaions of this class, but the general conotation remains intact.

Typically, the Cancelable interface is used to create a way to shutdown and exit elegantly. For example, transactions previously assigned to cancel()ed Database entity would not lost, they would be commited; but new transactions can not be submitted. Similarly, Executor objects can be cancel()ed so that they will finish run()ing thier current tasks, but won't accept new one.

Combining the Cancelable interface with the Waitable interface creates a method for disabling some object, and then waiting for that object to exit (to complete doing whatever it was doing as soon as possible).


Member Function Documentation

virtual void cancel   [pure virtual]
 

Canceling a Cancelable object is an indication that some part of its operation should be disabled. Canceling a Cancelable object more than once has no effect.

Exceptions:
Interrupted_Exception  should not be thrown.
Synchronization_Exception  thrown if there is some error in cancel()ing the object.
Postcondition:
The Cancelable object will have permanently transitioned to a canceled state.

Implemented in BlockingQueue, BoundedQueue, CancelableTask, ConcurrentExecutor, Executor, LockedQueue, MonitoredQueue, PoolExecutor, Queue, SynchronousExecutor, Thread, and ThreadedExecutor.

virtual bool isCanceled   [pure virtual]
 

Determine if a Cancelaeble object has been cancel()ed.

Returns :
bool true if cancel() was called prior to this method, otherwise false.
Exceptions:
Interrupted_Exception  should not be thrown.
Synchronization_Exception  thrown if there is some error in cancel()ing the object.

Implemented in BlockingQueue, BoundedQueue, CancelableTask, ConcurrentExecutor, LockedQueue, MonitoredQueue, PoolExecutor, SynchronousExecutor, Thread, and ThreadedExecutor.


The documentation for this class was generated from the following file:
Generated on Tue Aug 27 07:43:10 2002 for ZThread by doxygen1.2.17