public void execute(ExecutionOrder executionOrder, String executionMessage, ProgressMonitor pm) {
final Semaphore semaphore = new Semaphore(parallelism, true);
final TileComputationListener tcl = new OperatorTileComputationListener(semaphore, pm);
final TileComputationListener[] listeners = new TileComputationListener[]{tcl};
ImagingListener imagingListener = JAI.getDefaultInstance().getImagingListener();
JAI.getDefaultInstance().setImagingListener(new GPFImagingListener());
pm.beginTask(executionMessage, tileCountX * tileCountY * images.length);
ExecutionOrder effectiveExecutionOrder = getEffectiveExecutionOrder(executionOrder);
try {
if (effectiveExecutionOrder == ExecutionOrder.SCHEDULE_ROW_BAND_COLUMN) {
scheduleRowBandColumn(semaphore, listeners, pm);
} else if (effectiveExecutionOrder == ExecutionOrder.SCHEDULE_ROW_COLUMN_BAND) {
scheduleRowColumnBand(semaphore, pm);
} else if (effectiveExecutionOrder == ExecutionOrder.SCHEDULE_BAND_ROW_COLUMN) {
scheduleBandRowColumn(semaphore, listeners, pm);
} else if (effectiveExecutionOrder == ExecutionOrder.PULL_ROW_BAND_COLUMN) {
executeRowBandColumn(pm);
} else {
throw new IllegalArgumentException("executionOrder");
}
acquirePermits(semaphore, parallelism);
if (error != null) {
throw error;
}
} finally {
semaphore.release(parallelism);
pm.done();
JAI.getDefaultInstance().setImagingListener(imagingListener);
}
}