Skip to content

Commit

Permalink
fix: N5ScalePyramidExporter use correct ThreadPool for progress
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Oct 4, 2024
1 parent 13fd5b2 commit 3245930
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -284,6 +285,8 @@ public static enum DOWNSAMPLE_METHOD {

private final HashMap<Class<?>, N5MetadataWriter<?>> metadataWriters;

private ThreadPoolExecutor threadPool;

// consider something like this eventually
// private BiFunction<RandomAccessibleInterval<? extends
// NumericType<?>>,long[],RandomAccessibleInterval<?>> downsampler;
Expand Down Expand Up @@ -1201,14 +1204,16 @@ private <T extends RealType & NativeType, M extends N5Metadata> 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<Runnable>());
progressMonitor(threadPool);
N5Utils.save(image,
n5, dataset, chunkSize, compression,
Executors.newFixedThreadPool(nThreads));
threadPool);

writeMetadata(metadata, n5, dataset);
threadPool.shutdown();

return true;
}

Expand Down

0 comments on commit 3245930

Please sign in to comment.