mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Add threading debug
This commit is contained in:
parent
b1f5c0549c
commit
ce32613dd4
3 changed files with 22 additions and 11 deletions
|
@ -30,6 +30,7 @@ public class AppProperties {
|
||||||
boolean image;
|
boolean image;
|
||||||
boolean staging;
|
boolean staging;
|
||||||
boolean useVirtualThreads;
|
boolean useVirtualThreads;
|
||||||
|
boolean debugThreads;
|
||||||
Path dataDir;
|
Path dataDir;
|
||||||
boolean showcase;
|
boolean showcase;
|
||||||
|
|
||||||
|
@ -50,6 +51,9 @@ public class AppProperties {
|
||||||
useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads"))
|
useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads"))
|
||||||
.map(Boolean::parseBoolean)
|
.map(Boolean::parseBoolean)
|
||||||
.orElse(true);
|
.orElse(true);
|
||||||
|
debugThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.debugThreads"))
|
||||||
|
.map(Boolean::parseBoolean)
|
||||||
|
.orElse(false);
|
||||||
dataDir = XPipeInstallation.getDataDir();
|
dataDir = XPipeInstallation.getDataDir();
|
||||||
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
|
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
|
||||||
.map(Boolean::parseBoolean)
|
.map(Boolean::parseBoolean)
|
||||||
|
|
|
@ -2,22 +2,29 @@ package io.xpipe.app.util;
|
||||||
|
|
||||||
import io.xpipe.app.core.AppProperties;
|
import io.xpipe.app.core.AppProperties;
|
||||||
import io.xpipe.app.issue.ErrorEvent;
|
import io.xpipe.app.issue.ErrorEvent;
|
||||||
|
import io.xpipe.app.issue.TrackEvent;
|
||||||
import io.xpipe.core.util.FailableRunnable;
|
import io.xpipe.core.util.FailableRunnable;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class ThreadHelper {
|
public class ThreadHelper {
|
||||||
|
|
||||||
public static Thread unstarted(Runnable r) {
|
private static final AtomicInteger counter = new AtomicInteger();
|
||||||
return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(r) : Thread.ofPlatform().unstarted(r);
|
|
||||||
|
private static Runnable wrap(Runnable r) {
|
||||||
|
return () -> {
|
||||||
|
if (AppProperties.get().isDebugThreads()) {
|
||||||
|
TrackEvent.trace("Started. Active threads: " + counter.incrementAndGet());
|
||||||
|
}
|
||||||
|
r.run();
|
||||||
|
if (AppProperties.get().isDebugThreads()) {
|
||||||
|
TrackEvent.trace("Finished. Active threads: " + counter.decrementAndGet());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread unstartedFailable(FailableRunnable<Exception> r) {
|
public static Thread unstarted(Runnable r) {
|
||||||
return unstarted(() -> {
|
return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(wrap(r)) : Thread.ofPlatform().unstarted(wrap(r));
|
||||||
try {
|
|
||||||
r.run();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
ErrorEvent.fromThrowable(e).handle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread runAsync(Runnable r) {
|
public static Thread runAsync(Runnable r) {
|
||||||
|
|
|
@ -53,6 +53,6 @@ public class ChmodAction implements BranchAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
return List.of(new Chmod("600"), new Chmod("644"), new Chmod("700"), new Chmod("777"), new Chmod("u+x"), new Chmod("a+x"));
|
return List.of(new Chmod("400"), new Chmod("600"), new Chmod("644"), new Chmod("700"), new Chmod("777"), new Chmod("u+x"), new Chmod("a+x"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue