From: Jim Procter Date: Thu, 10 Oct 2019 14:13:38 +0000 (+0100) Subject: JAL-3070 use object identity equivalence for lists of workers and Cache.log.debug... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8dcca4766ed3d696a6160565ef43e21662557008;p=jalview.git JAL-3070 use object identity equivalence for lists of workers and Cache.log.debug messages --- diff --git a/src/jalview/workers/AlignCalcManager.java b/src/jalview/workers/AlignCalcManager.java index 3a3dc44..1967375 100644 --- a/src/jalview/workers/AlignCalcManager.java +++ b/src/jalview/workers/AlignCalcManager.java @@ -78,6 +78,19 @@ public class AlignCalcManager implements AlignCalcManagerI canUpdate = new HashSet<>(); } + private static boolean listContains(List upd, + AlignCalcWorkerI worker) + { + // avoid use of 'Contains' in case + for (AlignCalcWorkerI _otherworker : upd) + { + if (_otherworker == upd) + { + return true; + } + } + return false; + } @Override public void notifyStart(AlignCalcWorkerI worker) { @@ -91,18 +104,16 @@ public class AlignCalcManager implements AlignCalcManagerI } synchronized (upd) { - // avoid use of 'Contains' in case - for (AlignCalcWorkerI _otherworker : upd) + if (listContains(upd, worker)) { - if (_otherworker == upd) - { - Cache.log.debug( + Cache.log.debug( "Ignoring second call to notifyStart for worker " + worker); - return; - } } + else + { upd.add(worker); + } } } } @@ -139,7 +150,7 @@ public class AlignCalcManager implements AlignCalcManagerI { synchronized (inProgress) { - if (inProgress.contains(worker)) + if (listContains(inProgress, worker)) { return false; // worker is already working, so ask caller to wait around } @@ -156,7 +167,7 @@ public class AlignCalcManager implements AlignCalcManagerI { synchronized (inProgress) { - // System.err.println("Worker " + worker + " marked as complete."); + Cache.log.debug("Worker " + worker + " marked as complete."); inProgress.remove(worker); List upd = updating.get(worker.getClass()); if (upd != null) @@ -224,7 +235,7 @@ public class AlignCalcManager implements AlignCalcManagerI { synchronized (restartable) { - if (!restartable.contains(worker)) + if (!listContains(restartable, worker)) { restartable.add(worker); }