mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup pauses api
This commit is contained in:
@@ -161,7 +161,7 @@ public class ActionUtil {
|
||||
|
||||
String description = presentation.getText() + " action update (" + action.getClass() + ")";
|
||||
if (insidePerformDumbAwareUpdate++ == 0) {
|
||||
ActionPauses.STAT.started(description);
|
||||
ActionPauses.STAT.started();
|
||||
}
|
||||
try {
|
||||
if (beforeActionPerformed) {
|
||||
|
||||
+13
-24
@@ -1012,12 +1012,17 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
@Nullable JComponent parentComponent,
|
||||
@Nullable String cancelText,
|
||||
@NotNull Consumer<? super ProgressIndicator> action) {
|
||||
Class<?> clazz = action.getClass();
|
||||
startWrite(clazz);
|
||||
try {
|
||||
return runWriteActionWithClass(action.getClass(), ()->{
|
||||
PotemkinProgress indicator = new PotemkinProgress(title, project, parentComponent, cancelText);
|
||||
indicator.runInSwingThread(() -> action.consume(indicator));
|
||||
return !indicator.isCanceled();
|
||||
});
|
||||
}
|
||||
|
||||
private <T,E extends Throwable> T runWriteActionWithClass(@NotNull Class<?> clazz, @NotNull ThrowableComputable<T, E> computable) throws E {
|
||||
startWrite(clazz);
|
||||
try {
|
||||
return computable.compute();
|
||||
}
|
||||
finally {
|
||||
endWrite(clazz);
|
||||
@@ -1031,8 +1036,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
@Nullable String cancelText,
|
||||
@NotNull Consumer<? super ProgressIndicator> action) {
|
||||
Class<?> clazz = action.getClass();
|
||||
startWrite(clazz);
|
||||
try {
|
||||
return runWriteActionWithClass(clazz, ()->{
|
||||
PotemkinProgress indicator = new PotemkinProgress(title, project, parentComponent, cancelText);
|
||||
indicator.runInBackground(() -> {
|
||||
assert myWriteActionThread == null;
|
||||
@@ -1044,10 +1048,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
}
|
||||
});
|
||||
return !indicator.isCanceled();
|
||||
}
|
||||
finally {
|
||||
endWrite(clazz);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1065,25 +1066,13 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
@Override
|
||||
public <T> T runWriteAction(@NotNull final Computable<T> computation) {
|
||||
Class<? extends Computable> clazz = computation.getClass();
|
||||
startWrite(clazz);
|
||||
try {
|
||||
return computation.compute();
|
||||
}
|
||||
finally {
|
||||
endWrite(clazz);
|
||||
}
|
||||
return runWriteActionWithClass(clazz, () -> computation.compute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T, E extends Throwable> T runWriteAction(@NotNull ThrowableComputable<T, E> computation) throws E {
|
||||
Class<? extends ThrowableComputable> clazz = computation.getClass();
|
||||
startWrite(clazz);
|
||||
try {
|
||||
return computation.compute();
|
||||
}
|
||||
finally {
|
||||
endWrite(clazz);
|
||||
}
|
||||
return runWriteActionWithClass(clazz, computation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1227,7 +1216,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
HeavyProcessLatch.INSTANCE.stopThreadPrioritizing(); // let non-cancellable read actions complete faster, if present
|
||||
boolean writeActionPending = myWriteActionPending;
|
||||
if (gatherStatistics && myWriteActionsStack.isEmpty() && !writeActionPending) {
|
||||
ActionPauses.WRITE.started("write action ("+clazz+")");
|
||||
ActionPauses.WRITE.started();
|
||||
}
|
||||
myWriteActionPending = true;
|
||||
try {
|
||||
|
||||
@@ -35,7 +35,6 @@ public class PausesStat {
|
||||
private Object maxDurationDescription;
|
||||
private int totalNumberRecorded;
|
||||
private int indexToOverwrite; // used when pauses.size() == N_MAX and we have to overflow cyclically
|
||||
private String startDescription;
|
||||
|
||||
public PausesStat(@NotNull String name) {
|
||||
myName = name;
|
||||
@@ -53,13 +52,12 @@ public class PausesStat {
|
||||
}
|
||||
}
|
||||
|
||||
public void started(@NotNull String description) {
|
||||
public void started() {
|
||||
assertEdt();
|
||||
LOG.assertTrue(!started);
|
||||
LOG.assertTrue(startTimeStamp == 0, startTimeStamp);
|
||||
startTimeStamp = System.nanoTime();
|
||||
started = true;
|
||||
startDescription = description;
|
||||
}
|
||||
|
||||
private void assertEdt() {
|
||||
@@ -104,6 +102,6 @@ public class PausesStat {
|
||||
"\nTotal time spent: " + total + "ms" +
|
||||
"\nAverage duration: " + (number == 0 ? 0 : total / number) + "ms" +
|
||||
"\nMedian duration: " + ArrayUtil.averageAmongMedians(duration, 3) + "ms" +
|
||||
"\nMax duration: " + (maxDuration == 65535 ? ">" : "") + maxDuration+ "ms (it was '"+maxDurationDescription+"')";
|
||||
"\nMax duration: " + (maxDuration == 65535 ? ">" : "") + maxDuration+ "ms (it was '"+maxDurationDescription+"')";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user