java.lang.Object
com.hedera.hashgraph.sdk.CancellationSource
Creates a
Cancellation and is the only thing that can fire it.
Java has no standard cancellation type, so the SDK supplies one. Hand the getCancellation()
to a transport and keep the source; a transport that could cancel would be able to cancel the
caller's own operation.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Fire the cancellation.static CancellationSourcecreate()Create a new, uncancelled source.Extract the observer side, safe to hand to a transport.
-
Method Details
-
create
Create a new, uncancelled source.- Returns:
- the new source
-
getCancellation
Extract the observer side, safe to hand to a transport.- Returns:
- the cancellation this source fires
-
cancel
public void cancel()Fire the cancellation.Idempotent: a second call is a no-op, as is cancelling after the exchange has finished.
Cancellation.isCancelled()returns true before any observer runs, observers run synchronously on this thread, and one that throws neither stops the others nor propagates here.
-