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 * Returns the list of all workers for the given name or an empty list
40 List<AlignCalcWorkerI> getWorkersForName(String name);
43 * Removes the worker from the scheduler. It does not cancel workers
44 * already scheduled for execution.
46 void removeWorker(AlignCalcWorkerI worker);
49 * Removes all workers which are involved with the given annotation.
51 void removeWorkerForAnnotation(AlignmentAnnotation annot);
54 * Alias of removeWorkerForAnnotation
56 default void removeWorkersForAnnotation(AlignmentAnnotation annot) {
57 removeWorkerForAnnotation(annot);
61 * Removes all workers with matching name.
63 void removeWorkersForName(String name);
66 * Removes all workers of a given class. The classes are compared using
67 * {@link Class#equals(Object)}.
69 void removeWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
72 * Disables a worker so it won't be run during the following restarts.
74 void disableWorker(AlignCalcWorkerI worker);
77 * Restores the previously disabled worker back to operation.
79 void enableWorker(AlignCalcWorkerI worker);
82 * Checks whether the worker is disabled either due to failure or
83 * disabling it manually.
85 boolean isDisabled(AlignCalcWorkerI worker);
88 * Checks whether the given worker is currently running.
90 boolean isWorking(AlignCalcWorkerI worker);
93 * Checks whether the currently running worker (if any) is processing
94 * the given annotation.
96 boolean isWorkingWithAnnotation(AlignmentAnnotation annot);
99 * Checks whether this manager is running a worker.
104 * Scheduler the worker for one-time execution. The worker does not need
105 * to be registered with this manager and will be scheduler regardless
106 * of being disabled. If the worker has already been scheduled, the
107 * previous one will be cancelled.
109 void startWorker(AlignCalcWorkerI worker);
112 * Schedules all registered and not-disabled workers for next execution.
114 void restartWorkers();
117 * Cancels the execution of the worker. Note, if the worker is already
118 * running, this method may, but doesn't have to, interrupt it in
119 * the middle of the work.
121 void cancelWorker(AlignCalcWorkerI worker);
124 * Connect the listener of the worker state changes.
126 void addAlignCalcListener(AlignCalcListener listener);
129 * Remove previously registered worker listener.
131 void removeAlignCalcListener(AlignCalcListener listener);
134 * Stops the manager from running new jobs and cleans-up all
135 * resources such as threads and thread pools.