Skip to content

Commit

Permalink
Use one executor per resolution, instead of per series
Browse files Browse the repository at this point in the history
This means each resolution is written before proceeding to the next resolution.
  • Loading branch information
melissalinkert committed Jul 3, 2023
1 parent e7fd26e commit 9e9ab1e
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,6 @@ public void convertToPyramid()
InterruptedException, DependencyException
{
for (PyramidSeries s : series) {
executor = new ThreadPoolExecutor(
maxWorkers, maxWorkers, 0L, TimeUnit.MILLISECONDS, tileQueue);
convertPyramid(s);
}
StopWatch t0 = new Slf4JStopWatch("writeIFDs");
Expand All @@ -1179,8 +1177,11 @@ private void convertPyramid(PyramidSeries s)

int rgbChannels = s.rgb ? 3 : 1;
int bytesPerPixel = FormatTools.getBytesPerPixel(s.pixelType);
try {
for (int resolution=0; resolution<s.numberOfResolutions; resolution++) {
for (int resolution=0; resolution<s.numberOfResolutions; resolution++) {
executor = new ThreadPoolExecutor(
maxWorkers, maxWorkers, 0L, TimeUnit.MILLISECONDS, tileQueue);

try {
LOG.info("Converting resolution #{}", resolution);
ResolutionDescriptor descriptor = s.resolutions.get(resolution);
int tileCount = descriptor.numberOfTilesY * descriptor.numberOfTilesX;
Expand Down Expand Up @@ -1273,15 +1274,14 @@ private void convertPyramid(PyramidSeries s)
}
}
}

}
finally {
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
getProgressListener().notifyResolutionEnd(resolution);
}
}
finally {
executor.shutdown();
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
getProgressListener().notifySeriesEnd(s.index);
}
getProgressListener().notifySeriesEnd(s.index);
}

private void writeIFDs() throws FormatException, IOException {
Expand Down

0 comments on commit 9e9ab1e

Please sign in to comment.