Package smile.util
Class IterativeAlgorithmController<T>
java.lang.Object
smile.util.IterativeAlgorithmController<T>
- Type Parameters:
T
- the type of algorithm progress status objects.
- All Implemented Interfaces:
AutoCloseable
A controller for iterative algorithms.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.IterativeAlgorithmController
(Executor executor, int maxBufferCapacity) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
final boolean
Checks if keep algorithm going.void
stop()
Early stops the algorithm.void
Publishes the algorithm status to each current subscriber asynchronously.void
subscribe
(Flow.Subscriber<T> subscriber) Adds the given subscriber for algorithm progress.
-
Constructor Details
-
IterativeAlgorithmController
public IterativeAlgorithmController()Constructor. -
IterativeAlgorithmController
Constructor.- Parameters:
executor
- the executor to use for async delivery, supporting creation of at least one independent thread.maxBufferCapacity
- the maximum capacity for each subscriber's buffer.
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
isInterrupted
public final boolean isInterrupted()Checks if keep algorithm going.- Returns:
- true if keep algorithm going; false to early stop.
-
stop
public void stop()Early stops the algorithm. -
subscribe
Adds the given subscriber for algorithm progress.- Parameters:
subscriber
- the subscriber.
-
submit
Publishes the algorithm status to each current subscriber asynchronously.- Parameters:
status
- the algorithm progress information.
-