Package sc.fiji.snt
Record Class SNTUtils.BackgroundTask<T>
java.lang.Object
java.lang.Record
sc.fiji.snt.SNTUtils.BackgroundTask<T>
- Enclosing class:
SNTUtils
public static record SNTUtils.BackgroundTask<T>(Future<T> future, ExecutorService executor)
extends Record
Handle to a task submitted via
SNTUtils.submitBackground(java.util.concurrent.Callable<T>, java.lang.String): the running Future plus the
single-thread ExecutorService backing it, so a caller can wait on the same future repeatedly
(e.g. across a retry-prompt loop) and cancel/shut it down exactly once when done with it.-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundTask(Future<T> future, ExecutorService executor) Creates an instance of aBackgroundTaskrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Best-effort cancelsfutureand shuts downexecutor.final booleanIndicates whether some other object is "equal to" this one.executor()Returns the value of theexecutorrecord component.future()Returns the value of thefuturerecord component.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BackgroundTask
Creates an instance of aBackgroundTaskrecord class.- Parameters:
future- the value for thefuturerecord componentexecutor- the value for theexecutorrecord component
-
-
Method Details
-
cancel
public void cancel()Best-effort cancelsfutureand shuts downexecutor. No-op if already done. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
future
Returns the value of thefuturerecord component.- Returns:
- the value of the
futurerecord component
-
executor
Returns the value of theexecutorrecord component.- Returns:
- the value of the
executorrecord component
-