X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fworkers%2FAlignCalcManager.java;h=d94afb744dcd62cfc512a1b39189c87685616e48;hb=8eb35a7bab22595255245c5136dd780816b98f26;hp=c42e42419548e93596353c210d9b5cecaa614aa0;hpb=f61b2748a32ef03e687abc37b97640873c2e44aa;p=jalview.git
diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java
index c42e424..d94afb7 100644
--- a/src/jalview/workers/AlignCalcManager.java
+++ b/src/jalview/workers/AlignCalcManager.java
@@ -1,3 +1,20 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ *
+ * 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 .
+ */
package jalview.workers;
import java.util.ArrayList;
@@ -6,6 +23,7 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import jalview.api.AlignCalcManagerI;
import jalview.api.AlignCalcWorkerI;
@@ -62,7 +80,7 @@ public class AlignCalcManager implements AlignCalcManagerI
/*
* (non-Javadoc)
- *
+ *
* @see jalview.api.AlignCalcManagerI#isPending(jalview.api.AlignCalcWorkerI)
*/
@Override
@@ -131,6 +149,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 +183,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();
@@ -312,4 +333,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); } }
+ */
+ }
}