From 3245930530ed6416d8a4056d045ac5b2e2312dce Mon Sep 17 00:00:00 2001 From: John Bogovic Date: Fri, 4 Oct 2024 11:37:22 -0400 Subject: [PATCH] fix: N5ScalePyramidExporter use correct ThreadPool for progress --- .../saalfeldlab/n5/ij/N5ScalePyramidExporter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java b/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java index f62380b2..e41b52fd 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -284,6 +285,8 @@ public static enum DOWNSAMPLE_METHOD { private final HashMap, N5MetadataWriter> metadataWriters; + private ThreadPoolExecutor threadPool; + // consider something like this eventually // private BiFunction>,long[],RandomAccessibleInterval> downsampler; @@ -1201,14 +1204,16 @@ private boolean write( // Here, either allowing overwrite, or not allowing, but the dataset does not exist. // use threadPool even for single threaded execution for progress monitoring - final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, + threadPool = new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); progressMonitor(threadPool); N5Utils.save(image, n5, dataset, chunkSize, compression, - Executors.newFixedThreadPool(nThreads)); + threadPool); writeMetadata(metadata, n5, dataset); + threadPool.shutdown(); + return true; }