5 import jalview.datamodel.AlignmentAnnotation;
8 * An abstract manager which controls the execution of interactive jobs.
9 * There is always one instance of AlignCancManager per AlignmenViewport
10 * which runs the jobs, notifies observers and ensures no race conditions.
15 public interface AlignCalcManagerI2
18 * Registers the worker with the manager and immediately schedules it
21 void registerWorker(AlignCalcWorkerI worker);
24 * Returns the list of all registered workers or an empty list if
27 List<AlignCalcWorkerI> getWorkers();
30 * Returns the list of all workers of a given class or an empty list
31 * if there are none. The classes are compared using
32 * {@ink Class#equals(Object)} rather than {@code instanceof}.
34 List<AlignCalcWorkerI> getWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
37 * Removes the worker from the scheduler. It does not cancel workers
38 * already scheduled for execution.
40 void removeWorker(AlignCalcWorkerI worker);
43 * Removes all workers which are involved with the given annotation.
45 void removeWorkerForAnnotation(AlignmentAnnotation annot);
48 * Alias of removeWorkerForAnnotation
50 default void removeWorkersForAnnotation(AlignmentAnnotation annot) {
51 removeWorkerForAnnotation(annot);
55 * Removes all workers of a given class. The classes are compared using
56 * {@link Class#equals(Object)}.
58 void removeWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
61 * Disables a worker so it won't be run during the following restarts.
63 void disableWorker(AlignCalcWorkerI worker);
66 * Restores the previously disabled worker back to operation.
68 void enableWorker(AlignCalcWorkerI worker);
71 * Checks whether the worker is disabled either due to failure or
72 * disabling it manually.
74 boolean isDisabled(AlignCalcWorkerI worker);
77 * Checks whether the given worker is currently running.
79 boolean isWorking(AlignCalcWorkerI worker);
82 * Checks whether the currently running worker (if any) is processing
83 * the given annotation.
85 boolean isWorkingWithAnnotation(AlignmentAnnotation annot);
88 * Checks whether this manager is running a worker.
93 * Scheduler the worker for one-time execution. The worker does not need
94 * to be registered with this manager and will be scheduler regardless
95 * of being disabled. If the worker has already been scheduled, the
96 * previous one will be cancelled.
98 void startWorker(AlignCalcWorkerI worker);
101 * Schedules all registered and not-disabled workers for next execution.
103 void restartWorkers();
106 * Cancels the execution of the worker. Note, if the worker is already
107 * running, this method may, but doesn't have to, interrupt it in
108 * the middle of the work.
110 void cancelWorker(AlignCalcWorkerI worker);
113 * Connect the listener of the worker state changes.
115 void addAlignCalcListener(AlignCalcListener listener);
118 * Remove previously registered worker listener.
120 void removeAlignCalcListener(AlignCalcListener listener);
123 * Stops the manager from running new jobs and cleans-up all
124 * resources such as threads and thread pools.