mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Bug 503988 - UI thread got blocked by the reconciler
Change-Id: I176d9fd132291630aed3aeefb4a6279048c13d14
This commit is contained in:
parent
5cecbda67a
commit
2a3a9d6b4b
2 changed files with 23 additions and 3 deletions
|
@ -252,7 +252,13 @@ public class ASTCache {
|
||||||
IASTTranslationUnit ast= getAST(tUnit, index, wait, progressMonitor);
|
IASTTranslationUnit ast= getAST(tUnit, index, wait, progressMonitor);
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
try {
|
try {
|
||||||
((ASTTranslationUnit) ast).beginExclusiveAccess();
|
if (wait) {
|
||||||
|
((ASTTranslationUnit) ast).beginExclusiveAccess();
|
||||||
|
} else {
|
||||||
|
if (!((ASTTranslationUnit) ast).tryBeginExclusiveAccess(0)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
|
@ -493,13 +494,26 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts exclusive access
|
* Starts exclusive access.
|
||||||
* @throws InterruptedException
|
*
|
||||||
|
* @throws InterruptedException if the current thread is interrupted
|
||||||
*/
|
*/
|
||||||
public void beginExclusiveAccess() throws InterruptedException {
|
public void beginExclusiveAccess() throws InterruptedException {
|
||||||
fSemaphore.acquire();
|
fSemaphore.acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts exclusive access.
|
||||||
|
*
|
||||||
|
* @param timeoutMillis the maximum time to wait in milliseconds
|
||||||
|
* @return {@code true} if exclusive access was acquired, or {@code false} if it
|
||||||
|
* was not possible to acquire exclusive access before the timeout expired
|
||||||
|
* @throws InterruptedException if the current thread is interrupted
|
||||||
|
*/
|
||||||
|
public boolean tryBeginExclusiveAccess(long timeoutMillis) throws InterruptedException {
|
||||||
|
return fSemaphore.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
public void endExclusiveAccess() {
|
public void endExclusiveAccess() {
|
||||||
fSemaphore.release();
|
fSemaphore.release();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue