diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 273cc5a2..37a794fa 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -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); diff --git a/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java b/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java deleted file mode 100644 index bbb44ead..00000000 --- a/Launcher/src/main/java/ru/gravit/launcher/RequestWorker.java +++ /dev/null @@ -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 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"); - } -} diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index 882855e0..3b1acf9c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -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