java.lang.Object
com.hedera.hashgraph.sdk.Cancellation
A caller's request to end an exchange early, as observed by an
HttpTransport.
A transport observes one; it never creates one. Only CancellationSource can fire it, so a
third-party transport handed a Cancellation cannot cancel the caller's own operation.
Spelled Cancellation rather than CancellationSignal to avoid colliding with
android.os.CancellationSignal.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the caller has cancelled.static Cancellationnone()The value for a call with no caller-supplied cancellation.Observe the cancellation.
-
Constructor Details
-
Cancellation
Cancellation(@Nullable CancellationState state)
-
-
Method Details
-
none
The value for a call with no caller-supplied cancellation. Never null, and never fires.- Returns:
- a cancellation that is never cancelled
-
isCancelled
public boolean isCancelled()Whether the caller has cancelled.Returns true before any
onCancel(Runnable)callback runs.- Returns:
- true if cancelled
-
onCancel
Observe the cancellation.The callback runs synchronously on the thread that cancelled and must not block. Registering on an instance that has already been cancelled runs the callback immediately rather than never.
A transport must release its registration when the exchange ends — see
CancellationRegistration.- Parameters:
callback- the observer to run when the cancellation fires- Returns:
- a handle that stops the observation
-