X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fworkers%2FAlignCalcManager.java;h=10637063e3217a8448315cde0a4b2b9be2773bdb;hb=91c77a3db54eb4a270b03bcf9a6d97255c1fce35;hp=c42e42419548e93596353c210d9b5cecaa614aa0;hpb=f61b2748a32ef03e687abc37b97640873c2e44aa;p=jalview.git
diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java
index c42e424..1063706 100644
--- a/src/jalview/workers/AlignCalcManager.java
+++ b/src/jalview/workers/AlignCalcManager.java
@@ -1,15 +1,36 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.workers;
+import jalview.api.AlignCalcManagerI;
+import jalview.api.AlignCalcWorkerI;
+import jalview.datamodel.AlignmentAnnotation;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
-
-import jalview.api.AlignCalcManagerI;
-import jalview.api.AlignCalcWorkerI;
-import jalview.datamodel.AlignmentAnnotation;
+import java.util.Set;
public class AlignCalcManager implements AlignCalcManagerI
{
@@ -62,7 +83,7 @@ public class AlignCalcManager implements AlignCalcManagerI
/*
* (non-Javadoc)
- *
+ *
* @see jalview.api.AlignCalcManagerI#isPending(jalview.api.AlignCalcWorkerI)
*/
@Override
@@ -131,6 +152,7 @@ public class AlignCalcManager implements AlignCalcManagerI
{
synchronized (inProgress)
{
+ // System.err.println("Worker "+worker.getClass()+" marked as complete.");
inProgress.remove(worker.getClass());
List upd = updating.get(worker.getClass());
if (upd != null)
@@ -164,6 +186,8 @@ public class AlignCalcManager implements AlignCalcManagerI
@Override
public void startWorker(AlignCalcWorkerI worker)
{
+ // System.err.println("Starting "+worker.getClass());
+ // new Exception("").printStackTrace();
Thread tw = new Thread(worker);
tw.setName(worker.getClass().toString());
tw.start();
@@ -232,10 +256,12 @@ public class AlignCalcManager implements AlignCalcManagerI
for (List workers : updating.values())
{
for (AlignCalcWorkerI worker : workers)
+ {
if (worker.involves(alignmentAnnotation))
{
return true;
}
+ }
}
}
return false;
@@ -267,7 +293,7 @@ public class AlignCalcManager implements AlignCalcManagerI
AlignCalcWorkerI[] workers;
synchronized (canUpdate)
{
- workers = canUpdate.toArray(new AlignCalcWorkerI[0]);
+ workers = canUpdate.toArray(new AlignCalcWorkerI[canUpdate.size()]);
}
for (AlignCalcWorkerI worker : workers)
{
@@ -312,4 +338,48 @@ public class AlignCalcManager implements AlignCalcManagerI
}
}
}
+
+ @Override
+ public void removeRegisteredWorkersOfClass(Class typeToRemove)
+ {
+ List workers = getRegisteredWorkersOfClass(typeToRemove);
+ List removable = new ArrayList();
+ Set toremovannot = new HashSet();
+ synchronized (restartable)
+ {
+ for (AlignCalcWorkerI worker : restartable)
+ {
+ if (typeToRemove.equals(worker.getClass()))
+ {
+ removable.add(worker);
+ toremovannot.add(worker);
+ }
+ }
+ restartable.removeAll(removable);
+ }
+ synchronized (canUpdate)
+ {
+ for (AlignCalcWorkerI worker : canUpdate)
+ {
+ if (typeToRemove.equals(worker.getClass()))
+ {
+ removable.add(worker);
+ toremovannot.add(worker);
+ }
+ }
+ canUpdate.removeAll(removable);
+ }
+ // TODO: finish testing this extension
+
+ /*
+ * synchronized (inProgress) { // need to kill or mark as dead any running
+ * threads... (inProgress.get(typeToRemove)); }
+ *
+ * if (workers == null) { return; } for (AlignCalcWorkerI worker : workers)
+ * {
+ *
+ * if (isPending(worker)) { worker.abortAndDestroy(); startWorker(worker); }
+ * else { System.err.println("Pending exists for " + workerClass); } }
+ */
+ }
}