java.lang.Object
com.hedera.hashgraph.sdk.CancellationRegistration
- All Implemented Interfaces:
AutoCloseable
The handle returned by
Cancellation.onCancel(Runnable), used to stop observing.
Releasing is not optional. An application that holds one CancellationSource across many
calls — "cancel everything on logout", which is the use the type exists for — would otherwise
accumulate one dead closure per exchange for the lifetime of that source. It is the
addEventListener without removeEventListener leak, and a single-use rule would not
fix it because nothing can enforce one.
Implements AutoCloseable so it can be released from a try-with-resources block;
close() is exactly release() and throws nothing.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()(package private) static CancellationRegistrationnoop()(package private) static CancellationRegistrationof(CancellationState state, Runnable callback) voidrelease()Stop observing.
-
Method Details
-
of
-
noop
-
release
public void release()Stop observing. Idempotent, and a no-op once the cancellation has already fired. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-