mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-11 11:55:03 -05:00
Allow custom parallelism for formats
This commit is contained in:
parent
468ded44aa
commit
b6251a7aa5
@ -22,6 +22,7 @@ import net.filebot.UserFiles.FileChooser;
|
||||
import net.filebot.cli.ArgumentBean;
|
||||
import net.filebot.util.PreferencesList;
|
||||
import net.filebot.util.PreferencesMap;
|
||||
import net.filebot.util.SystemProperty;
|
||||
import net.filebot.util.PreferencesMap.JsonAdapter;
|
||||
import net.filebot.util.PreferencesMap.PreferencesEntry;
|
||||
import net.filebot.util.PreferencesMap.StringAdapter;
|
||||
@ -129,16 +130,11 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static int getPreferredThreadPoolSize() {
|
||||
try {
|
||||
String threadPool = System.getProperty("threadPool");
|
||||
if (threadPool != null) {
|
||||
return Integer.parseInt(threadPool);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
return SystemProperty.of("threadPool", Integer::parseInt, Runtime.getRuntime().availableProcessors()).get();
|
||||
}
|
||||
|
||||
return Runtime.getRuntime().availableProcessors();
|
||||
public static int getPreferredParallelism() {
|
||||
return SystemProperty.of("parallelism", Integer::parseInt, 1).get();
|
||||
}
|
||||
|
||||
public static LicenseModel getLicenseModel() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.filebot.ui.rename;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.Settings.*;
|
||||
import static net.filebot.util.ExceptionUtilities.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
@ -16,8 +17,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@ -162,7 +162,7 @@ public class RenameModel extends MatchModel<Object, File> {
|
||||
|
||||
private final List<FormattedFuture> futures = new ArrayList<FormattedFuture>();
|
||||
|
||||
private final Executor backgroundFormatter = new ThreadPoolExecutor(0, 1, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
||||
private final Executor backgroundFormatter = Executors.newFixedThreadPool(getPreferredParallelism());
|
||||
|
||||
public FormattedFutureEventList(EventList<Object> source) {
|
||||
super(source);
|
||||
|
Loading…
Reference in New Issue
Block a user