From: Mateusz Warowny Date: Wed, 2 Mar 2022 17:26:24 +0000 (+0100) Subject: JAL-3878 Add serviceExecutor to AlignmentViewport. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=33984339919481bc4679641250870acb9f929d90;hp=043a8dc72cc33a55d868874dfd486238aedfa5fc;p=jalview.git JAL-3878 Add serviceExecutor to AlignmentViewport. The serviceExecutor is a ScheduledExecutorService which (web)services can use to run jobs associated with the current viewport. --- diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 1a08b1b..c9165d0 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -74,6 +74,9 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; /** * base class holding visualization and analysis attributes and common logic for @@ -995,6 +998,20 @@ public abstract class AlignmentViewport return false; } + private ScheduledExecutorService serviceExecutor = Executors.newSingleThreadScheduledExecutor(); + + /** + * Get a default scheduled executor service which can be used by + * services and calculators to run parallel jobs associated with this + * viewport. + * + * @return default service executor of that viewport + */ + public ScheduledExecutorService getServiceExecutor() + { + return serviceExecutor; + } + public void setAlignment(AlignmentI align) { this.alignment = align; @@ -1024,6 +1041,8 @@ public abstract class AlignmentViewport gapcounts = null; calculator.shutdown(); calculator = null; + serviceExecutor.shutdown(); + serviceExecutor = null; residueShading = null; // may hold a reference to Consensus changeSupport = null; ranges = null;