@Beta @PublicAPI public interface CancelObserver
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.
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.