Ticket #12376: josm-12376-MultipolygonBuilder-invokeAll-tasks.patch

File josm-12376-MultipolygonBuilder-invokeAll-tasks.patch, 1.6 KB (added by cmuelle8, 9 years ago)

josm-12376-MultipolygonBuilder-invokeAll-tasks.patch

  • src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java

     
    375375
    376376        @Override
    377377        protected List<PolygonLevel> compute() {
    378             if (to - from < directExecutionTaskSize) {
     378            if (to - from <= directExecutionTaskSize) {
    379379                return computeDirectly();
    380380            } else {
    381381                final Collection<ForkJoinTask<List<PolygonLevel>>> tasks = new ArrayList<>();
    382382                for (int fromIndex = from; fromIndex < to; fromIndex += directExecutionTaskSize) {
    383                     final List<PolygonLevel> output = new ArrayList<>();
    384                     tasks.add(new Worker(input, fromIndex, Math.min(fromIndex + directExecutionTaskSize, to), output, directExecutionTaskSize));
     383                    tasks.add(new Worker(input, fromIndex, Math.min(fromIndex + directExecutionTaskSize, to), new ArrayList<PolygonLevel>(), directExecutionTaskSize));
    385384                }
    386                 for (ForkJoinTask<List<PolygonLevel>> task : tasks) {
    387                     output.addAll(task.join());
     385                for (ForkJoinTask<List<PolygonLevel>> task : ForkJoinTask.invokeAll(tasks)) {
     386                    List<PolygonLevel> res = task.join();
     387                    if (res == null) {
     388                        return null;
     389                    }
     390                    output.addAll(res);
    388391                }
    389392                return output;
    390393            }