* An abstract manager which controls the execution of interactive jobs.
* There is always one instance of AlignCancManager per AlignmenViewport
* which runs the jobs, notifies observers and ensures no race conditions.
- *
+ *
* @author mmwarowny
*
*/
* for execution.
*/
void registerWorker(AlignCalcWorkerI worker);
-
+
/**
- * Returns the list of all registered workers or an empty list if
+ * Returns the list of all registered workers or an empty list if
* there are none
*/
List<AlignCalcWorkerI> getWorkers();
-
+
/**
* Returns the list of all workers of a given class or an empty list
- * if there are none. The classes are compared using
+ * if there are none. The classes are compared using
* {@ink Class#equals(Object)} rather than {@code instanceof}.
*/
List<AlignCalcWorkerI> getWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
-
+
+ /**
+ * Returns the list of all workers for the given name or an empty list
+ * if there are none.
+ */
+ List<AlignCalcWorkerI> getWorkersForName(String name);
+
/**
* Removes the worker from the scheduler. It does not cancel workers
* already scheduled for execution.
*/
void removeWorker(AlignCalcWorkerI worker);
-
+
/**
* Removes all workers which are involved with the given annotation.
*/
void removeWorkerForAnnotation(AlignmentAnnotation annot);
-
+
/**
* Alias of removeWorkerForAnnotation
*/
default void removeWorkersForAnnotation(AlignmentAnnotation annot) {
removeWorkerForAnnotation(annot);
}
-
+
+ /**
+ * Removes all workers with matching name.
+ */
+ void removeWorkersForName(String name);
+
/**
* Removes all workers of a given class. The classes are compared using
- * {@link Class#equals(Object)}.
+ * {@link Class#equals(Object)}.
*/
void removeWorkersOfClass(Class<? extends AlignCalcWorkerI> cls);
-
+
/**
* Disables a worker so it won't be run during the following restarts.
*/
void disableWorker(AlignCalcWorkerI worker);
-
+
/**
* Restores the previously disabled worker back to operation.
*/
void enableWorker(AlignCalcWorkerI worker);
-
+
/**
* Checks whether the worker is disabled either due to failure or
* disabling it manually.
*/
boolean isDisabled(AlignCalcWorkerI worker);
-
+
/**
* Checks whether the given worker is currently running.
*/
boolean isWorking(AlignCalcWorkerI worker);
-
+
/**
* Checks whether the currently running worker (if any) is processing
* the given annotation.
*/
boolean isWorkingWithAnnotation(AlignmentAnnotation annot);
-
+
/**
* Checks whether this manager is running a worker.
*/
boolean isWorking();
-
+
/**
* Scheduler the worker for one-time execution. The worker does not need
* to be registered with this manager and will be scheduler regardless
* previous one will be cancelled.
*/
void startWorker(AlignCalcWorkerI worker);
-
+
/**
* Schedules all registered and not-disabled workers for next execution.
*/
void restartWorkers();
-
+
/**
* Cancels the execution of the worker. Note, if the worker is already
* running, this method may, but doesn't have to, interrupt it in
* the middle of the work.
*/
void cancelWorker(AlignCalcWorkerI worker);
-
+
/**
* Connect the listener of the worker state changes.
*/
void addAlignCalcListener(AlignCalcListener listener);
-
+
/**
* Remove previously registered worker listener.
*/
void removeAlignCalcListener(AlignCalcListener listener);
-
+
/**
* Stops the manager from running new jobs and cleans-up all
* resources such as threads and thread pools.
}
@Override
+ public List<AlignCalcWorkerI> getWorkersForName(String name)
+ {
+ List<AlignCalcWorkerI> collected = new ArrayList<>();
+ for (var worker : getWorkers())
+ {
+ if (worker.getCalcName().equals(name))
+ {
+ collected.add(worker);
+ }
+ }
+ return collected;
+ }
+
+ @Override
public void removeWorker(AlignCalcWorkerI worker)
{
if (worker.isDeletable())
}
@Override
+ public void removeWorkersForName(String name)
+ {
+ synchronized (registered)
+ {
+ for (var worker : getWorkers())
+ {
+ if (worker.getCalcName().equals(name))
+ {
+ removeWorker(worker);
+ }
+ }
+ }
+ }
+
+ @Override
public void disableWorker(AlignCalcWorkerI worker)
{
// Null pointer check might be needed