use of com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator in project intellij-community by JetBrains.
the class ProgressIndicatorTest method testSOEUnderExtremelyNestedWrappedIndicator.
public void testSOEUnderExtremelyNestedWrappedIndicator() {
ProgressIndicator indicator = new DaemonProgressIndicator();
for (int i = 0; i < 10000; i++) {
indicator = new SensitiveProgressWrapper(indicator);
}
ProgressManager.getInstance().executeProcessUnderProgress(() -> {
ProgressIndicator progressIndicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
assertTrue(progressIndicator instanceof SensitiveProgressWrapper);
progressIndicator.checkCanceled();
progressIndicator.isCanceled();
}, indicator);
}
use of com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator in project intellij-community by JetBrains.
the class PsiConcurrencyStressTest method testStress.
public void testStress() throws Exception {
DaemonProgressIndicator.setDebug(false);
int numOfThreads = Runtime.getRuntime().availableProcessors();
int iterations = Timings.adjustAccordingToMySpeed(20, true);
System.out.println("iterations = " + iterations);
final int readIterations = iterations * 3;
synchronized (this) {
PsiClass myClass = myJavaFacade.findClass("StressClass", GlobalSearchScope.allScope(myProject));
assertNotNull(myClass);
myFile = (PsiJavaFile) myClass.getContainingFile();
}
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
final CountDownLatch reads = new CountDownLatch(numOfThreads);
final Random random = new Random();
List<Thread> threads = ContainerUtil.map(Collections.nCopies(numOfThreads, ""), i -> new Thread(() -> {
for (int i1 = 0; i1 < readIterations; i1++) {
if (myPsiManager == null)
return;
ProgressManager.getInstance().runProcess(() -> ApplicationManager.getApplication().runReadAction(() -> {
assertFalse(writeActionInProgress);
readStep(random);
}), new DaemonProgressIndicator());
}
reads.countDown();
}, "stress thread" + i));
threads.forEach(Thread::start);
final Document document = documentManager.getDocument(myFile);
for (int i = 0; i < iterations; i++) {
Thread.sleep(100);
new WriteCommandAction(myProject, myFile) {
@Override
protected void run(@NotNull final Result result) throws Throwable {
writeActionInProgress = true;
documentManager.commitAllDocuments();
writeStep(random);
documentManager.commitAllDocuments();
assertEquals(document.getText(), myFile.getText());
writeActionInProgress = false;
}
}.execute();
}
assertTrue("Timed out", reads.await(5, TimeUnit.MINUTES));
ConcurrencyUtil.joinAll(threads);
}
use of com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator in project intellij-community by JetBrains.
the class JobUtilTest method testDaemonDoesNotPauseWhenEventDispatcherHasEventsInTheQueue.
public void testDaemonDoesNotPauseWhenEventDispatcherHasEventsInTheQueue() throws Throwable {
assertTrue(SwingUtilities.isEventDispatchThread());
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue();
final AtomicInteger jobsStarted = new AtomicInteger();
final int N_EVENTS = 50;
final int N_JOBS = 10000 * JobSchedulerImpl.CORES_COUNT;
ProgressIndicator indicator = new DaemonProgressIndicator();
Job<Void> job = JobLauncher.getInstance().submitToJobThread(() -> JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(N_JOBS, null), indicator, false, o -> {
jobsStarted.incrementAndGet();
TimeoutUtil.sleep(10);
return true;
}), null);
for (int i = 0; i < N_EVENTS; i++) {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> {
int jobs0 = jobsStarted.get();
long start = System.currentTimeMillis();
while (jobsStarted.get() < jobs0 + JobSchedulerImpl.CORES_COUNT && jobsStarted.get() < N_JOBS) {
if (System.currentTimeMillis() > start + 10000) {
System.err.println(ThreadDumper.dumpThreadsToString());
fail();
break;
}
}
//int jobs1 = jobsStarted.get();
//System.out.println("jobs0 = "+jobs0+"; jobs1 = "+jobs1);
});
UIUtil.dispatchAllInvocationEvents();
}
indicator.cancel();
job.cancel();
while (!job.isDone()) {
try {
job.waitForCompletion(1000);
UIUtil.dispatchAllInvocationEvents();
break;
} catch (TimeoutException ignored) {
}
}
}
Aggregations