Class CancelSource<E extends RuntimeException>
java.lang.Object
io.temporal.internal.concurrent.structured.CancelSource<E>
- Type Parameters:
E- the exception surfaced by the token when cancellation is requested
The write side of cancellation. Whoever holds the
CancelSource can request
cancellation while everyone else observes using token().
Sources can be linked: a source created via linkedTo(java.util.function.Supplier<E>, io.temporal.common.CancellationToken<? extends E>...) is cancelled
automatically when any of its parent tokens is cancelled, without giving the child the power to
cancel the parent.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Requests cancellation with a freshly created exception.voidRequests cancellation, surfacingexceptionfrom the token.booleanstatic <E extends RuntimeException>
CancelSource<E> linkedTo(Supplier<E> defaultException, CancellationToken<? extends E>... parents) Creates a source whose token is cancelled (viacancel()) whenever anyparenttoken is cancelled.token()The read-only token to hand to code that observes cancellation.
-
Constructor Details
-
CancelSource
-
-
Method Details
-
token
The read-only token to hand to code that observes cancellation. -
isCancelled
public boolean isCancelled() -
cancel
public void cancel()Requests cancellation with a freshly created exception. -
cancel
Requests cancellation, surfacingexceptionfrom the token. Idempotent. -
linkedTo
@SafeVarargs public static <E extends RuntimeException> CancelSource<E> linkedTo(Supplier<E> defaultException, CancellationToken<? extends E>... parents) Creates a source whose token is cancelled (viacancel()) whenever anyparenttoken is cancelled.
-