Package com.uber.cadence.workflow
Interface CancellationScope
-
- All Superinterfaces:
java.lang.Runnable
public interface CancellationScope extends java.lang.Runnable
Handle to a cancellation scope created throughWorkflow.newCancellationScope(Runnable)
orWorkflow.newDetachedCancellationScope(Runnable)
. Supports explicit cancelling of the code a cancellation scope wraps. The code in the CancellationScope has to be executed usingRunnable.run()
method.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancel()
Cancels the scope as well as all its childrenvoid
cancel(java.lang.String reason)
Cancels the scope as well as all its children.static CancellationScope
current()
java.lang.String
getCancellationReason()
Promise<java.lang.String>
getCancellationRequest()
Use this promise to perform cancellation of async operations.boolean
isCancelRequested()
Is scope was asked to cancel throughcancel()
or by a parent scope.boolean
isDetached()
When set to false parent thread cancellation causes this one to get cancelled automatically.static void
throwCancelled()
ThrowsCancellationException
if scope is cancelled.
-
-
-
Method Detail
-
isDetached
boolean isDetached()
When set to false parent thread cancellation causes this one to get cancelled automatically. When set to true only call tocancel()
leads to this scope cancellation.
-
cancel
void cancel()
Cancels the scope as well as all its children
-
cancel
void cancel(java.lang.String reason)
Cancels the scope as well as all its children.- Parameters:
reason
- human readable reason for the cancellation. Becomes message of the CancellationException thrown.
-
getCancellationReason
java.lang.String getCancellationReason()
-
isCancelRequested
boolean isCancelRequested()
Is scope was asked to cancel throughcancel()
or by a parent scope.- Returns:
- whether request is cancelled or not.
-
getCancellationRequest
Promise<java.lang.String> getCancellationRequest()
Use this promise to perform cancellation of async operations.- Returns:
- promise that becomes ready when scope is cancelled. It contains reason value or null if none was provided.
-
current
static CancellationScope current()
-
throwCancelled
static void throwCancelled() throws java.util.concurrent.CancellationException
ThrowsCancellationException
if scope is cancelled. Noop if not cancelled.- Throws:
java.util.concurrent.CancellationException
-
-