Skip to content

Commit

Permalink
refs LibraryOfCongress#121 - only use as many threads as CPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
jscancella authored and Richard van Heest committed Feb 20, 2019
1 parent 1fce68f commit 3cc8f2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class BagVerifier implements AutoCloseable{
* {@link StandardBagitAlgorithmNameToSupportedAlgorithmMapping}
*/
public BagVerifier(){
this(Executors.newCachedThreadPool(), new StandardBagitAlgorithmNameToSupportedAlgorithmMapping());
this(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), new StandardBagitAlgorithmNameToSupportedAlgorithmMapping());
}

/**
Expand All @@ -54,7 +54,7 @@ public BagVerifier(){
* @param nameMapping the mapping between BagIt algorithm name and the java supported algorithm
*/
public BagVerifier(final BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping){
this(Executors.newCachedThreadPool(), nameMapping);
this(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), nameMapping);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ManifestVerifier implements AutoCloseable{
* {@link StandardBagitAlgorithmNameToSupportedAlgorithmMapping} mapping
*/
public ManifestVerifier(){
this(new StandardBagitAlgorithmNameToSupportedAlgorithmMapping(), Executors.newCachedThreadPool());
this(new StandardBagitAlgorithmNameToSupportedAlgorithmMapping(), Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
}

/**
Expand All @@ -52,7 +52,7 @@ public ManifestVerifier(){
* @param nameMapping the mapping between BagIt algorithm name and the java supported algorithm
*/
public ManifestVerifier(final BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping) {
this(nameMapping, Executors.newCachedThreadPool());
this(nameMapping, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CheckIfFileExistsTaskTest extends TempFolderTest {

@Test
public void testNormalizedFileExists() throws Exception{
ExecutorService executor = Executors.newCachedThreadPool();
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
CountDownLatch latch = new CountDownLatch(1);
Set<Path> missingFiles = new ConcurrentSkipListSet<>();
String filename = "Núñez.txt";
Expand Down

0 comments on commit 3cc8f2f

Please sign in to comment.