Кеширование HWID, получение HWID в отдельном потоке

This commit is contained in:
Gravit 2018-12-29 17:26:15 +07:00
parent cf5867c131
commit 9af4145ab7
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 7 additions and 1 deletions

View file

@ -191,6 +191,7 @@ public void start(String... args) throws Throwable {
// Load init.js script
FunctionalBridge.worker = new RequestWorker();
CommonHelper.newThread("FX Task Worker", true, FunctionalBridge.worker).start();
CommonHelper.newThread("GetHWID Thread",true, FunctionalBridge::getHWID).start();
loadScript(Launcher.API_SCRIPT_FILE);
loadScript(Launcher.CONFIG_SCRIPT_FILE);
LogHelper.debug("Dir: %s", DirBridge.dir);

View file

@ -18,6 +18,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.security.SignatureException;
import java.util.concurrent.atomic.AtomicReference;
public class FunctionalBridge {
@LauncherAPI
@ -26,6 +27,8 @@ public class FunctionalBridge {
public static RequestWorker worker;
@LauncherAPI
public static OshiHWIDProvider hwidProvider = new OshiHWIDProvider();
@LauncherAPI
public static AtomicReference<HWID> hwid = new AtomicReference<>();
@LauncherAPI
public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, SignedObjectHolder<HashedDir> hdir, FileNameMatcher matcher, boolean digest) throws Exception {
@ -69,7 +72,9 @@ public static void startTask(@SuppressWarnings("rawtypes") Task task) {
@LauncherAPI
public static HWID getHWID() {
return hwidProvider.getHWID();
HWID hhwid = hwid.get();
if(hhwid == null) hwid.set(hwidProvider.getHWID());
return hhwid;
}
@LauncherAPI