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 * Removes all workers of a given class. The classes are compared using
49 * {@link Class#equals(Object)}.
51 void removeWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
54 * Disables a worker so it won't be run during the following restarts.
56 void disableWorker(AlignCalcWorkerI worker);
59 * Restores the previously disabled worker back to operation.
61 void enableWorker(AlignCalcWorkerI worker);
64 * Checks whether the worker is disabled either due to failure or
65 * disabling it manually.
67 boolean isDisabled(AlignCalcWorkerI worker);
70 * Checks whether the given worker is currently running.
72 boolean isWorking(AlignCalcWorkerI worker);
75 * Checks whether the currently running worker (if any) is processing
76 * the given annotation.
78 boolean isWorkingWithAnnotation(AlignmentAnnotation annot);
81 * Checks whether this manager is running a worker.
86 * Scheduler the worker for one-time execution. The worker does not need
87 * to be registered with this manager and will be scheduler regardless
88 * of being disabled. If the worker has already been scheduled, the
89 * previous one will be cancelled.
91 void startWorker(AlignCalcWorkerI worker);
94 * Schedules all registered and not-disabled workers for next execution.
96 void restartWorkers();
99 * Cancels the execution of the worker. Note, if the worker is already
100 * running, this method may, but doesn't have to, interrupt it in
101 * the middle of the work.
103 void cancelWorker(AlignCalcWorkerI worker);
106 * Connect the listener of the worker state changes.
108 void addAlignCalcListener(AlignCalcListener listener);
111 * Remove previously registered worker listener.
113 void removeAlignCalcListener(AlignCalcListener listener);
116 * Stops the manager from running new jobs and cleans-up all
117 * resources such as threads and thread pools.