mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +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 staging;
|
||||
boolean useVirtualThreads;
|
||||
boolean debugThreads;
|
||||
Path dataDir;
|
||||
boolean showcase;
|
||||
|
||||
|
@ -50,6 +51,9 @@ public class AppProperties {
|
|||
useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(true);
|
||||
debugThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.debugThreads"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(false);
|
||||
dataDir = XPipeInstallation.getDataDir();
|
||||
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
|
||||
.map(Boolean::parseBoolean)
|
||||
|
|
|
@ -2,22 +2,29 @@ package io.xpipe.app.util;
|
|||
|
||||
import io.xpipe.app.core.AppProperties;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.core.util.FailableRunnable;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ThreadHelper {
|
||||
|
||||
public static Thread unstarted(Runnable r) {
|
||||
return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(r) : Thread.ofPlatform().unstarted(r);
|
||||
private static final AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
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) {
|
||||
return unstarted(() -> {
|
||||
try {
|
||||
r.run();
|
||||
} catch (Throwable e) {
|
||||
ErrorEvent.fromThrowable(e).handle();
|
||||
}
|
||||
});
|
||||
public static Thread unstarted(Runnable r) {
|
||||
return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(wrap(r)) : Thread.ofPlatform().unstarted(wrap(r));
|
||||
}
|
||||
|
||||
public static Thread runAsync(Runnable r) {
|
||||
|
|
|
@ -53,6 +53,6 @@ public class ChmodAction implements BranchAction {
|
|||
|
||||
@Override
|
||||
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