mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Переход на ThreadPool.
This commit is contained in:
parent
7c5c4faa75
commit
90b91a9635
3 changed files with 4 additions and 40 deletions
|
@ -71,8 +71,6 @@ public void start(String... args) throws Throwable {
|
|||
throw new IllegalStateException("Launcher has been already started");
|
||||
Launcher.modulesManager.initModules();
|
||||
runtimeProvider.preLoad();
|
||||
FunctionalBridge.worker = new RequestWorker();
|
||||
CommonHelper.newThread("Task Worker", true, FunctionalBridge.worker).start();
|
||||
FunctionalBridge.getHWID = CommonHelper.newThread("GetHWID Thread", true, FunctionalBridge::getHWID);
|
||||
FunctionalBridge.getHWID.start();
|
||||
LogHelper.debug("Dir: %s", DirBridge.dir);
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package ru.gravit.launcher;
|
||||
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class RequestWorker implements Runnable {
|
||||
public RequestWorker() {
|
||||
queue = new LinkedBlockingQueue<>(64);
|
||||
}
|
||||
|
||||
public BlockingQueue<Runnable> queue;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LogHelper.debug("FX Task Thread start");
|
||||
while (!Thread.interrupted()) {
|
||||
try {
|
||||
Runnable task;
|
||||
task = queue.take();
|
||||
task.run();
|
||||
} catch (InterruptedException e) {
|
||||
LogHelper.error(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
LogHelper.debug("FX Task Thread done");
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
import javafx.concurrent.Task;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.RequestWorker;
|
||||
import ru.gravit.launcher.hasher.FileNameMatcher;
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
import ru.gravit.launcher.hwid.OshiHWIDProvider;
|
||||
|
@ -13,17 +12,18 @@
|
|||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class FunctionalBridge {
|
||||
@LauncherAPI
|
||||
public static LauncherSettings settings;
|
||||
@LauncherAPI
|
||||
public static RequestWorker worker;
|
||||
public static ExecutorService worker = Executors.newWorkStealingPool();
|
||||
@LauncherAPI
|
||||
public static OshiHWIDProvider hwidProvider = new OshiHWIDProvider();
|
||||
@LauncherAPI
|
||||
|
@ -64,11 +64,7 @@ public static void makeJsonRequest(RequestInterface request, Runnable callback)
|
|||
|
||||
@LauncherAPI
|
||||
public static void startTask(@SuppressWarnings("rawtypes") Task task) {
|
||||
try {
|
||||
worker.queue.put(task);
|
||||
} catch (InterruptedException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
worker.execute(task);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
|
|
Loading…
Reference in a new issue