#include <Cancelable.h>
Inheritance diagram for Cancelable:
Public Methods | |
virtual | ~Cancelable () throw () |
Destroy a Cancelable object. | |
virtual void | cancel ()=0 |
virtual bool | isCanceled ()=0 |
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).
|
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.
Implemented in BlockingQueue, BoundedQueue, CancelableTask, ConcurrentExecutor, Executor, LockedQueue, MonitoredQueue, PoolExecutor, Queue, SynchronousExecutor, Thread, and ThreadedExecutor. |
|
Determine if a Cancelaeble object has been cancel()ed.
Implemented in BlockingQueue, BoundedQueue, CancelableTask, ConcurrentExecutor, LockedQueue, MonitoredQueue, PoolExecutor, SynchronousExecutor, Thread, and ThreadedExecutor. |