IDEA-84204 IDEA hang up after trying to rename private static field

This commit is contained in:
Alexey Kudravtsev
2012-04-16 13:54:24 +04:00
parent e5a6b12edc
commit 3fe4b30e1a
2 changed files with 25 additions and 17 deletions
@@ -15,27 +15,32 @@
*/
package com.intellij.openapi.application.impl;
import com.intellij.concurrency.JobScheduler;
import com.intellij.openapi.util.Condition;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.Processor;
import com.intellij.util.containers.TransferToEDTQueue;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.ScheduledThreadPoolExecutor;
/**
* Allows to process elements in the Application pooled thread.
* Processes elements in batches, no longer than 200ms per batch, and reschedules processing later for longer batches.
* Passes elements for processing in the dedicated thread.
* Processes elements in batches, no longer than {maxUnitOfWorkThresholdMs}ms per batch, and reschedules processing later for longer batches.
* Usage: {@link #offer(Object)} } : schedules element for processing in a pooled thread
*/
public class TransferToPooledThreadQueue<T> extends TransferToEDTQueue<T> {
public TransferToPooledThreadQueue(@NotNull String name,
@NotNull Processor<T> processorInEDT,
private final ScheduledThreadPoolExecutor myExecutor = ConcurrencyUtil.newSingleScheduledThreadExecutor("Encoding detection thread");
public TransferToPooledThreadQueue(@NonNls @NotNull String name,
@NotNull Condition<?> shutUpCondition,
int maxUnitOfWorkThresholdMs) {
super(name, processorInEDT, shutUpCondition, maxUnitOfWorkThresholdMs);
int maxUnitOfWorkThresholdMs,
@NotNull Processor<T> processor) {
super(name, processor, shutUpCondition, maxUnitOfWorkThresholdMs);
}
@Override
protected void schedule(@NotNull Runnable updateRunnable) {
JobScheduler.getScheduler().execute(updateRunnable);
myExecutor.execute(updateRunnable);
}
}
@@ -86,15 +86,18 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
private static final Key<Charset> CACHED_CHARSET_FROM_CONTENT = Key.create("CACHED_CHARSET_FROM_CONTENT");
private final TransferToPooledThreadQueue<Reference<Document>> myChangedDocuments = new TransferToPooledThreadQueue<Reference<Document>>(
"Loading documents", new Processor<Reference<Document>>() {
@Override
public boolean process(Reference<Document> ref) {
Document document = ref.get();
if (document == null) return true; // document gced, don't bother
handleDocument(document);
return true;
}
}, ApplicationManager.getApplication().getDisposed(), -1); // drain the whole queue, do not reschedule
"Loading documents",
ApplicationManager.getApplication().getDisposed(),
-1, // drain the whole queue, do not reschedule
new Processor<Reference<Document>>() {
@Override
public boolean process(Reference<Document> ref) {
Document document = ref.get();
if (document == null) return true; // document gced, don't bother
handleDocument(document);
return true;
}
});
public EncodingManagerImpl(EditorFactory editorFactory) {
editorFactory.getEventMulticaster().addDocumentListener(new DocumentAdapter() {