From 33984339919481bc4679641250870acb9f929d90 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 2 Mar 2022 18:26:24 +0100 Subject: [PATCH 1/1] JAL-3878 Add serviceExecutor to AlignmentViewport. The serviceExecutor is a ScheduledExecutorService which (web)services can use to run jobs associated with the current viewport. --- src/jalview/viewmodel/AlignmentViewport.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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; -- 1.7.10.2