mandala.util
Interface Cancelable

All Known Subinterfaces:
FutureClient, RemoteCancelable, RemoteFutureClient
All Known Implementing Classes:
AbstractFutureClient, RemoteCancelableProxy, RMICancelable, ThreadPool.ThreadPoolCancelable

public interface Cancelable

Interface for Cancelable operation.

An operation is anything which can be runned by a thread. Cancelling an operation remove it from a virtual list of operations to be runned. Implementation are not supposed to use such a list, but for the end-user point of view, operations are in virtual lists, cancelling an operation, remove it from a list. Canceled operation may be reinserted in another virtual list in order to get a chance to be re-executed. Interrupting an operation means interrupting the thread which is running it. Of course, interrupting a terminated operation or a not yet started operation has no effect.

Usually, when a user want to stop an operation it requires two steps :

This may be written:
 if (!operation.cancel()) operation.interrupt();

Since:
1.0
Version:
1.0
Author:
eipi

Method Summary
 boolean cancel()
          Cancel the operation related to this cancelable object.
 boolean interrupt()
          Interrupt the operation related to this cancelable object.
 

Method Detail

cancel

public boolean cancel()

Cancel the operation related to this cancelable object.

This method does nothing if the related operation is already started or terminated.

This method returns true if the related operation has been succesfully cancelled, false otherwise.

Returns:
true if the related operation has been succesfully cancelled, false otherwise

interrupt

public boolean interrupt()

Interrupt the operation related to this cancelable object.

Interruption of an operation means that the thread which is running the related operation is interrupted. It is the responsibilty of the operation to check the interrupt status of the current thread (see Thread.interrupted() in order to be able to return as soon as possible on interruption.

This method does nothing if the related operation is not started yet or if it is already terminated.

This method returns true if the related operation has been succesfully interrupted, false otherwise.

Returns:
true if the related operation has been succesfully interrupted, false otherwise.


Mandala help mailing list