mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't delay each small write action in the single Save by async filters (IDEA-163365)
This commit is contained in:
@@ -26,7 +26,6 @@ import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import one.util.streamex.IntStreamEx;
|
||||
@@ -89,7 +88,7 @@ class AsyncFilterRunner {
|
||||
applyResults.set(bgComputation.compute());
|
||||
};
|
||||
while (!ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(computeInReadAction)) {
|
||||
TimeoutUtil.sleep(10);
|
||||
ProgressIndicatorUtils.yieldToPendingWriteActions();
|
||||
}
|
||||
return applyResults.get();
|
||||
}
|
||||
|
||||
+10
@@ -19,11 +19,13 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationAdapter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.ui.EdtInvocationManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -225,4 +227,12 @@ public class ProgressIndicatorUtils {
|
||||
}
|
||||
}, progressIndicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the current EDT activity finishes in case it requires many write actions, with each being delayed a bit
|
||||
* by background thread read action (until its first checkCanceled call).
|
||||
*/
|
||||
public static void yieldToPendingWriteActions() {
|
||||
ApplicationManager.getApplication().invokeAndWait(EmptyRunnable.INSTANCE, ModalityState.any());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user