Skip to content

Commit

Permalink
Remove redundant ForkJoinPool, submitting and then waiting is just ru…
Browse files Browse the repository at this point in the history
…nning on a background thread.
  • Loading branch information
johnmay authored and egonw committed Feb 6, 2022
1 parent d053229 commit e3320f2
Showing 1 changed file with 2 additions and 19 deletions.
Expand Up @@ -39,11 +39,7 @@ and associated documentation files (the "Software"), to deal in the Software wit
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.group.Permutation;
Expand Down Expand Up @@ -2594,21 +2590,8 @@ public void structureGenerator(String localFormula) {
List<int[]> newDegrees = distributeHydrogens();

if (multiThread) {
try {
new ForkJoinPool(size)
.submit(
() ->
newDegrees
.parallelStream()
.forEach(new Generation(this)::run))
.get();
} catch (InterruptedException | ExecutionException ex) {
if (verbose) {
Logger.getLogger(Maygen.class.getName())
.log(Level.SEVERE, ex, () -> "Formula " + localFormula);
}
Thread.currentThread().interrupt();
}
newDegrees.parallelStream()
.forEach(new Generation(this)::run);
} else {
newDegrees.forEach(new Generation(this)::run);
}
Expand Down

0 comments on commit e3320f2

Please sign in to comment.