X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fstartup%2FConcurrentComponentPresetDatabaseLoader.java;h=3a70b7e505a27fe660c4452d03e9ff6042797187;hb=ad5f7d00bae736b56692b55db75bbdff6f772b9c;hp=a4191da3cf6a4e33e82fd805b3d9a5dcce8483c7;hpb=5b151571d47ae9917234049b429ffa98983a3053;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/startup/ConcurrentComponentPresetDatabaseLoader.java b/core/src/net/sf/openrocket/startup/ConcurrentComponentPresetDatabaseLoader.java index a4191da3..3a70b7e5 100644 --- a/core/src/net/sf/openrocket/startup/ConcurrentComponentPresetDatabaseLoader.java +++ b/core/src/net/sf/openrocket/startup/ConcurrentComponentPresetDatabaseLoader.java @@ -49,7 +49,7 @@ public class ConcurrentComponentPresetDatabaseLoader { } }); - loaderPool = Executors.newFixedThreadPool(15, new ThreadFactory() { + loaderPool = Executors.newFixedThreadPool(3, new ThreadFactory() { int threadCount = 0; @Override public Thread newThread(Runnable r) { @@ -70,10 +70,12 @@ public class ConcurrentComponentPresetDatabaseLoader { public void await() throws InterruptedException { latch.await(); loaderPool.shutdown(); - loaderPool.awaitTermination(10, TimeUnit.SECONDS); + loaderPool.awaitTermination(90, TimeUnit.SECONDS); writerPool.shutdown(); - writerPool.awaitTermination(10, TimeUnit.SECONDS); - iterator.close(); + writerPool.awaitTermination(90, TimeUnit.SECONDS); + if ( iterator != null ) { + iterator.close(); + } long end = System.currentTimeMillis(); log.debug("Time to load presets: " + (end-startTime) + "ms " + presetCount + " loaded from " + fileCount + " files"); } @@ -88,18 +90,14 @@ public class ConcurrentComponentPresetDatabaseLoader { iterator = DirectoryIterator.findDirectory(SYSTEM_PRESET_DIR, new SimpleFileFilter("", false, "orc")); - if (iterator == null) { - throw new IllegalStateException("Component preset directory " + SYSTEM_PRESET_DIR + - " not found, distribution built wrong"); - } - - while( iterator.hasNext() ) { - Pair f = iterator.next(); - FileLoader loader = new FileLoader( f.getV(), f.getU() ); - loaderPool.execute(loader); - fileCount ++; + if (iterator != null) { + while( iterator.hasNext() ) { + Pair f = iterator.next(); + FileLoader loader = new FileLoader( f.getV(), f.getU() ); + loaderPool.execute(loader); + fileCount ++; + } } - latch.countDown(); } }