cancel dumps as early as possible

GitOrigin-RevId: a40937891b1b1d316e9d6c3bf5257d92da3d8d79
This commit is contained in:
Egor Ushakov
2019-09-10 16:02:34 +00:00
committed by intellij-monorepo-bot
parent 1cf60d9952
commit d4461ac66f
@@ -45,7 +45,7 @@ public final class PerformanceWatcher implements Disposable {
private static final int TOLERABLE_LATENCY = 100;
private static final String THREAD_DUMPS_PREFIX = "threadDumps-";
private ScheduledFuture<?> myThread;
private SamplingTask myDumpTask;
private volatile SamplingTask myDumpTask;
private final File myLogDir = new File(PathManager.getLogPath());
private List<StackTraceElement> myStacktraceCommonPart;
@@ -261,8 +261,9 @@ public final class PerformanceWatcher implements Disposable {
}
private void stopDumping() {
if (myDumpTask != null) {
myDumpTask.stop();
SamplingTask task = myDumpTask;
if (task != null) {
task.stop();
}
}
@@ -295,9 +296,11 @@ public final class PerformanceWatcher implements Disposable {
}
public void edtEventFinished() {
if (myCurrentEDTEventChecker != null) {
if (!myCurrentEDTEventChecker.cancel(false)) {
Future<?> currentChecker = myCurrentEDTEventChecker;
if (currentChecker != null) {
if (!currentChecker.cancel(false)) {
long end = System.currentTimeMillis();
stopDumping(); // stop sampling as early as possible
try {
myExecutor.submit(() -> edtResponds(end)).get();
}