alt: rename natives directory

This commit is contained in:
huanghongxun 2020-02-22 23:13:52 +08:00
parent fb4a499fe9
commit 1ca4045a2f
3 changed files with 7 additions and 27 deletions

View File

@ -54,10 +54,6 @@ public final class DownloadProviders {
() -> Optional.ofNullable(providersById.get(config().getDownloadType())) () -> Optional.ofNullable(providersById.get(config().getDownloadType()))
.orElse(providersById.get(DEFAULT_PROVIDER_ID)), .orElse(providersById.get(DEFAULT_PROVIDER_ID)),
config().downloadTypeProperty()); config().downloadTypeProperty());
FXUtils.onChangeAndOperate(downloadProviderProperty, provider -> {
Schedulers.io().setMaximumPoolSize(provider.getConcurrency());
});
} }
/** /**

View File

@ -118,7 +118,7 @@ public class DefaultGameRepository implements GameRepository {
@Override @Override
public File getNativeDirectory(String id) { public File getNativeDirectory(String id) {
return new File(getVersionRoot(id), id + "-natives"); return new File(getVersionRoot(id), "natives");
} }
@Override @Override

View File

@ -42,33 +42,20 @@ public final class Schedulers {
return CACHED_EXECUTOR; return CACHED_EXECUTOR;
} }
private static volatile ThreadPoolExecutor IO_EXECUTOR; private static volatile ExecutorService IO_EXECUTOR;
public static synchronized ThreadPoolExecutor io() { public static synchronized ExecutorService io() {
if (IO_EXECUTOR == null) if (IO_EXECUTOR == null) {
IO_EXECUTOR = new ThreadPoolExecutor(6, 6, int threads = Math.min(Runtime.getRuntime().availableProcessors() * 4, 64);
60L, TimeUnit.SECONDS, IO_EXECUTOR = Executors.newFixedThreadPool(threads,
new LinkedBlockingQueue<>(),
runnable -> { runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable); Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true); thread.setDaemon(true);
return thread; return thread;
}); });
return IO_EXECUTOR;
} }
private static volatile ExecutorService SINGLE_EXECUTOR; return IO_EXECUTOR;
public static synchronized ExecutorService computation() {
if (SINGLE_EXECUTOR == null)
SINGLE_EXECUTOR = Executors.newSingleThreadExecutor(runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);
return thread;
});
return SINGLE_EXECUTOR;
} }
public static Executor javafx() { public static Executor javafx() {
@ -91,9 +78,6 @@ public final class Schedulers {
if (IO_EXECUTOR != null) if (IO_EXECUTOR != null)
IO_EXECUTOR.shutdownNow(); IO_EXECUTOR.shutdownNow();
if (SINGLE_EXECUTOR != null)
SINGLE_EXECUTOR.shutdownNow();
} }
public static Future<?> schedule(Executor executor, Runnable command) { public static Future<?> schedule(Executor executor, Runnable command) {