diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-03-06 09:48:54 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-03-06 09:48:54 +0100 |
commit | 9dd4c4880b42dd17c3bbaf1662eee9d8bbcad748 (patch) | |
tree | f9e8639fd015093c033c189bc00c94a2bac2087b /container-core/src/main/java/com/yahoo/processing | |
parent | 351903b75e5cf8feaa6606c139ee56e1caeccd23 (diff) |
Shutdown renderer threads on deconstruct
Diffstat (limited to 'container-core/src/main/java/com/yahoo/processing')
-rw-r--r-- | container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java b/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java index 3980ec80423..b54757cac50 100644 --- a/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java +++ b/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java @@ -114,6 +114,8 @@ public abstract class AsynchronousSectionedRenderer<RESPONSE extends Response> e // We should complete any work we have already started so use an unbounded queue. // The executor SHOULD be reused across all instances having the same prototype private final Executor renderingExecutor; + // The executor may either be created (and thus owned) by this, or passed by injection + private final boolean renderingExecutorIsOwned; private static ThreadPoolExecutor createExecutor() { int threadCount = Runtime.getRuntime().availableProcessors(); @@ -150,7 +152,14 @@ public abstract class AsynchronousSectionedRenderer<RESPONSE extends Response> e */ public AsynchronousSectionedRenderer(Executor executor) { isInitialized = false; - renderingExecutor = executor==null ? createExecutor() : executor; + if (executor == null) { + renderingExecutor = createExecutor(); + renderingExecutorIsOwned = true; + } + else { + renderingExecutor = executor; + renderingExecutorIsOwned = false; + } } /** @@ -184,7 +193,7 @@ public abstract class AsynchronousSectionedRenderer<RESPONSE extends Response> e @Override public void deconstruct() { super.deconstruct(); - if (renderingExecutor instanceof ThreadPoolExecutor) + if (renderingExecutorIsOwned && renderingExecutor instanceof ThreadPoolExecutor) shutdown((ThreadPoolExecutor) renderingExecutor); } |