Interface CancellationPoint
- All Superinterfaces:
AutoCloseable,CancelCheck,Cancellable
- All Known Implementing Classes:
DefaultCancellationPoint,DelegatingCancellationPoint,DummyCancellationPoint
Interface for cancellation points;
We create cancellation point in one place and have a contract that we don't dispose system or don't drop database while the point is active and
actual;
-
Field Summary
Fields inherited from interface com.complexible.common.cancellation.CancelCheck
DUMMY -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancel current point;voidclose()Closes cancellation point;static CancellationPointforCancelCheck(String description, CancelCheck check) Wraps the non-cancellableCancelCheckas a cancellableCancellationPoint.Returns null if the process has not been cancelled, otherwise the cancellation cause (if set).Returns the description of the process that this cancellation point represents.static CancellationPointReturns a cancellation point which can be checked but cannot be closed.voidWaits for specified timeout while the process acquired Cancellation point has been finished;Methods inherited from interface com.complexible.common.cancellation.CancelCheck
check, check, isCancelled, throwIfCancelledMethods inherited from interface com.complexible.common.cancellation.Cancellable
cancel
-
Method Details
-
getProcessDescription
String getProcessDescription()Returns the description of the process that this cancellation point represents.- Returns:
- the process description.
-
cancel
void cancel()Cancel current point; -
getCancellationMessage
Description copied from interface:CancelCheckReturns null if the process has not been cancelled, otherwise the cancellation cause (if set).- Specified by:
getCancellationMessagein interfaceCancelCheck- Returns:
- cancellation message used for cancel;
-
wait
void wait(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Waits for specified timeout while the process acquired Cancellation point has been finished;- Parameters:
timeout- - the time;unit- - the unit;- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
close
void close()Closes cancellation point;- Specified by:
closein interfaceAutoCloseable
-
uncloseable
Returns a cancellation point which can be checked but cannot be closed. Useful for passing a cancellation point into processes which don't own it and are not supposed to close it. -
forCancelCheck
Wraps the non-cancellableCancelCheckas a cancellableCancellationPoint. This is supposed to be used in those rare cases when a process can be cancelled externally (i.e. gets aCancelCheckfrom the outer code) but also spawns sub-processes which it can cancel itself. This method makes it easier to ensure that sub-processes get cancelled both from outside of the main process and from inside it. Note: the returned object does not supportwaiting.- Parameters:
description- the process descriptioncheck- the external cancellation check- Returns:
- the cancellation point which is cancelled either via its cancel method or when the external flag is raised.
-