mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-06-30 20:10:57 +12:00
Use platform threads in development mode instead of virtual ones
This commit is contained in:
parent
454e8aea75
commit
8c4c68f24a
|
@ -142,6 +142,7 @@ application {
|
||||||
}
|
}
|
||||||
|
|
||||||
run {
|
run {
|
||||||
|
systemProperty 'io.xpipe.app.useVirtualThreads', 'false'
|
||||||
systemProperty 'io.xpipe.app.mode', 'gui'
|
systemProperty 'io.xpipe.app.mode', 'gui'
|
||||||
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local7/"
|
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local7/"
|
||||||
systemProperty 'io.xpipe.app.writeLogs', "true"
|
systemProperty 'io.xpipe.app.writeLogs', "true"
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class AppFileWatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
watcherThread = ThreadHelper.create("file watcher", true, () -> {
|
watcherThread = ThreadHelper.createPlatformThread("file watcher", true, () -> {
|
||||||
while (active) {
|
while (active) {
|
||||||
WatchKey key;
|
WatchKey key;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class AppMainWindow {
|
||||||
private synchronized void onChange() {
|
private synchronized void onChange() {
|
||||||
lastUpdate = Instant.now();
|
lastUpdate = Instant.now();
|
||||||
if (thread == null) {
|
if (thread == null) {
|
||||||
thread = ThreadHelper.create("window change timeout", true, () -> {
|
thread = ThreadHelper.createPlatformThread("window change timeout", true, () -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
var toStop = lastUpdate.plus(Duration.of(1, ChronoUnit.SECONDS));
|
var toStop = lastUpdate.plus(Duration.of(1, ChronoUnit.SECONDS));
|
||||||
if (Instant.now().isBefore(toStop)) {
|
if (Instant.now().isBefore(toStop)) {
|
||||||
|
|
|
@ -21,14 +21,17 @@ public class AppProperties {
|
||||||
private static final String EXTENSION_PATHS_PROP = "io.xpipe.app.extensions";
|
private static final String EXTENSION_PATHS_PROP = "io.xpipe.app.extensions";
|
||||||
private static AppProperties INSTANCE;
|
private static AppProperties INSTANCE;
|
||||||
boolean fullVersion;
|
boolean fullVersion;
|
||||||
|
@Getter
|
||||||
String version;
|
String version;
|
||||||
|
@Getter
|
||||||
String build;
|
String build;
|
||||||
UUID buildUuid;
|
UUID buildUuid;
|
||||||
String sentryUrl;
|
String sentryUrl;
|
||||||
String arch;
|
String arch;
|
||||||
|
@Getter
|
||||||
boolean image;
|
boolean image;
|
||||||
boolean staging;
|
boolean staging;
|
||||||
@Getter
|
boolean useVirtualThreads;
|
||||||
Path dataDir;
|
Path dataDir;
|
||||||
boolean showcase;
|
boolean showcase;
|
||||||
|
|
||||||
|
@ -48,6 +51,9 @@ public class AppProperties {
|
||||||
staging = Optional.ofNullable(System.getProperty("io.xpipe.app.staging"))
|
staging = Optional.ofNullable(System.getProperty("io.xpipe.app.staging"))
|
||||||
.map(Boolean::parseBoolean)
|
.map(Boolean::parseBoolean)
|
||||||
.orElse(false);
|
.orElse(false);
|
||||||
|
useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads"))
|
||||||
|
.map(Boolean::parseBoolean)
|
||||||
|
.orElse(true);
|
||||||
dataDir = parseDataDir();
|
dataDir = parseDataDir();
|
||||||
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
|
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
|
||||||
.map(Boolean::parseBoolean)
|
.map(Boolean::parseBoolean)
|
||||||
|
@ -106,10 +112,6 @@ public class AppProperties {
|
||||||
return Path.of(System.getProperty("user.home"), isStaging() ? ".xpipe_stage" : ".xpipe");
|
return Path.of(System.getProperty("user.home"), isStaging() ? ".xpipe_stage" : ".xpipe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDeveloperMode() {
|
public boolean isDeveloperMode() {
|
||||||
if (AppPrefs.get() == null) {
|
if (AppPrefs.get() == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -118,11 +120,4 @@ public class AppProperties {
|
||||||
return AppPrefs.get().developerMode().getValue();
|
return AppPrefs.get().developerMode().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBuild() {
|
|
||||||
return build;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public abstract class OperationMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchToAsync(OperationMode newMode) {
|
public static void switchToAsync(OperationMode newMode) {
|
||||||
ThreadHelper.create("mode switcher", false, () -> switchTo(newMode)).start();
|
ThreadHelper.createPlatformThread("mode switcher", false, () -> switchTo(newMode)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchTo(OperationMode newMode) {
|
public static void switchTo(OperationMode newMode) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public abstract class PlatformMode extends OperationMode {
|
||||||
TrackEvent.info("mode", "Finished essential component initialization before platform");
|
TrackEvent.info("mode", "Finished essential component initialization before platform");
|
||||||
|
|
||||||
TrackEvent.info("mode", "Launching application ...");
|
TrackEvent.info("mode", "Launching application ...");
|
||||||
ThreadHelper.create("app", false, () -> {
|
ThreadHelper.createPlatformThread("app", false, () -> {
|
||||||
TrackEvent.info("mode", "Application thread started");
|
TrackEvent.info("mode", "Application thread started");
|
||||||
Application.launch(App.class);
|
Application.launch(App.class);
|
||||||
})
|
})
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class BindingsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ThreadHelper.create("referenceGC", true, () -> {
|
ThreadHelper.createPlatformThread("referenceGC", true, () -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
for (ReferenceEntry reference : REFERENCES) {
|
for (ReferenceEntry reference : REFERENCES) {
|
||||||
if (reference.canGc()) {
|
if (reference.canGc()) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public abstract class UpdateHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startBackgroundUpdater() {
|
private void startBackgroundUpdater() {
|
||||||
ThreadHelper.create("updater", true, () -> {
|
ThreadHelper.createPlatformThread("updater", true, () -> {
|
||||||
ThreadHelper.sleep(Duration.ofMinutes(5).toMillis());
|
ThreadHelper.sleep(Duration.ofMinutes(5).toMillis());
|
||||||
event("Starting background updater thread");
|
event("Starting background updater thread");
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
package io.xpipe.app.util;
|
package io.xpipe.app.util;
|
||||||
|
|
||||||
|
import io.xpipe.app.core.AppProperties;
|
||||||
import io.xpipe.app.issue.ErrorEvent;
|
import io.xpipe.app.issue.ErrorEvent;
|
||||||
import org.apache.commons.lang3.function.FailableRunnable;
|
import org.apache.commons.lang3.function.FailableRunnable;
|
||||||
|
|
||||||
public class ThreadHelper {
|
public class ThreadHelper {
|
||||||
|
|
||||||
|
private static Thread unstarted(Runnable r) {
|
||||||
|
return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(r) : Thread.ofPlatform().unstarted(r);
|
||||||
|
}
|
||||||
|
|
||||||
public static Thread runAsync(Runnable r) {
|
public static Thread runAsync(Runnable r) {
|
||||||
var t = Thread.ofVirtual().unstarted(r);
|
var t = unstarted(r);
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
t.start();
|
t.start();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread runFailableAsync(FailableRunnable<Throwable> r) {
|
public static Thread runFailableAsync(FailableRunnable<Throwable> r) {
|
||||||
var t = Thread.ofVirtual().unstarted(() -> {
|
var t = unstarted(() -> {
|
||||||
try {
|
try {
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -25,7 +30,7 @@ public class ThreadHelper {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread create(String name, boolean daemon, Runnable r) {
|
public static Thread createPlatformThread(String name, boolean daemon, Runnable r) {
|
||||||
var t = new Thread(r);
|
var t = new Thread(r);
|
||||||
t.setDaemon(daemon);
|
t.setDaemon(daemon);
|
||||||
t.setName(name);
|
t.setName(name);
|
||||||
|
|
1
dist/debug/debug_arguments.txt
vendored
1
dist/debug/debug_arguments.txt
vendored
|
@ -3,3 +3,4 @@
|
||||||
-Dio.xpipe.app.logLevel=trace
|
-Dio.xpipe.app.logLevel=trace
|
||||||
-Dio.xpipe.app.developerMode=true
|
-Dio.xpipe.app.developerMode=true
|
||||||
-Dio.xpipe.beacon.debugOutput=true
|
-Dio.xpipe.beacon.debugOutput=true
|
||||||
|
-Dio.xpipe.app.useVirtualThreads=false
|
Loading…
Reference in a new issue