public interface CancellationScope
extends java.lang.Runnable
Workflow.newCancellationScope(Runnable)
or
Workflow.newDetachedCancellationScope(Runnable)
. Supports explicit cancelling of the code
a cancellation scope wraps. The code in the CancellationScope has to be executed using Runnable.run()
method.Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the scope as well as all its children
|
void |
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 through
cancel() or by a parent scope. |
boolean |
isDetached()
When set to false parent thread cancellation causes this one to get canceled automatically.
|
static void |
throwCanceled()
Throws
CanceledFailure if scope is canceled. |
boolean isDetached()
cancel()
leads to this scope cancellation.void cancel()
void cancel(java.lang.String reason)
reason
- human readable reason for the cancellation. Becomes message of the
CanceledException thrown.java.lang.String getCancellationReason()
boolean isCancelRequested()
cancel()
or by a parent scope.Promise<java.lang.String> getCancellationRequest()
static CancellationScope current()
static void throwCanceled() throws CanceledFailure
CanceledFailure
if scope is canceled. Noop if not canceled.CanceledFailure