Package io.temporal.workflow
Interface CancellationScope
-
- All Superinterfaces:
java.lang.Runnable
- All Known Subinterfaces:
WorkflowThread
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 canceled automatically.static void
throwCanceled()
ThrowsCanceledFailure
if scope is canceled.
-
-
-
Method Detail
-
isDetached
boolean isDetached()
When set to false parent thread cancellation causes this one to get canceled 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 CanceledException 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 canceled 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 canceled. It contains reason value or null if none was provided.
-
current
static CancellationScope current()
-
throwCanceled
static void throwCanceled() throws CanceledFailure
ThrowsCanceledFailure
if scope is canceled. Noop if not canceled.- Throws:
CanceledFailure
-
-