mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not use busy loop
This commit is contained in:
+1
@@ -250,6 +250,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
if (callbackWhileWaiting != null) {
|
||||
callbackWhileWaiting.run();
|
||||
}
|
||||
myPassExecutorService.waitFor(50);
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
Throwable savedException = PassExecutorService.getSavedException(progress);
|
||||
if (savedException != null) throw savedException;
|
||||
|
||||
+19
-4
@@ -47,12 +47,10 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -519,4 +517,21 @@ public abstract class PassExecutorService implements Disposable {
|
||||
public static Throwable getSavedException(DaemonProgressIndicator indicator) {
|
||||
return indicator.getUserData(THROWABLE_KEY);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void waitFor(int millis) throws Exception {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
try {
|
||||
for (Job<Void> job : mySubmittedPasses.values()) {
|
||||
if (!job.isDone()) {
|
||||
for (FutureTask task : ((JobImpl)job).getTasks()) {
|
||||
task.get(millis, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (TimeoutException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user