mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45: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);
|
||||
if (ast != null) {
|
||||
try {
|
||||
((ASTTranslationUnit) ast).beginExclusiveAccess();
|
||||
if (wait) {
|
||||
((ASTTranslationUnit) ast).beginExclusiveAccess();
|
||||
} else {
|
||||
if (!((ASTTranslationUnit) ast).tryBeginExclusiveAccess(0)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
|
@ -493,13 +494,26 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
|
||||
/**
|
||||
* Starts exclusive access
|
||||
* @throws InterruptedException
|
||||
* Starts exclusive access.
|
||||
*
|
||||
* @throws InterruptedException if the current thread is interrupted
|
||||
*/
|
||||
public void beginExclusiveAccess() throws InterruptedException {
|
||||
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() {
|
||||
fSemaphore.release();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue