Interface CancelObserver
-
- All Known Subinterfaces:
ProgressObserver
,SubProgressObserver
@Beta @PublicAPI public interface CancelObserver
Callback to propagate cancel requests into long running tasks.Cancel request propagation is part of the functionality provided by
ProgressObserver
, however it is a cross cutting concern, so it is exposed as a separate interface.Thread safety: implementations are not required to be thread safe. Observed processes must be prepared for working with non thread safe observers. Consequently observer methods can be called only on the thread invoked the observed function. Alternatively proper synchronization must be ensured by the observed code.
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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
isCancelled()
Returns whether cancellation of current operation has been requested.
-
-
-
Method Detail
-
isCancelled
boolean isCancelled()
Returns whether cancellation of current operation has been requested.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 atrue
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.- Returns:
- true if cancellation has been requested, false otherwise.
-
-