@Beta public class CancelObserverImpl extends Object implements CancelObserver
CancelObserver
.
Please note that this interface is marked with @Beta annotation, so it can be subject of incompatible changes or removal in any of the later releases.
Constructor and Description |
---|
CancelObserverImpl()
Constructor for a cancellable observer implementation.
|
CancelObserverImpl(CancelObserver sourceCanceller)
Constructor with an underlying polling source.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Sign cancelling.
|
boolean |
isCancelled()
Returns whether cancellation of current operation has been requested.
|
public CancelObserverImpl()
public CancelObserverImpl(CancelObserver sourceCanceller)
sourceCanceller
- canceller to pollpublic void cancel()
Note that this implementation is not thread safe, so this method must be invoked from the thread created/using this instance.
public boolean isCancelled()
CancelObserver
Long running/memory intensive operations should poll to see if cancelation has been requested. Since time-out based cancelations might be implemented polling should not be done too often.
It is expected that implementations wont return false
after a true
value returned.
It is also expected that implementations tolerate multiple calls regardless of the cancallation state.
Please note that test cases might check for too frequent invocations, so the propagation of any
AssertionError
thrown by this method should not be obstructed.
It is usually expected that the cancelled task should throw
CancellationException
and this behavior should be documented in their APIdocs.
isCancelled
in interface CancelObserver