1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Bug 442794: Speed up cancellation of PDOMIndexerJob.ProgressUpdateJob.

This commit is contained in:
Markus Schorn 2014-08-29 07:37:33 +02:00
parent 554c753e31
commit 8c148855bf

View file

@ -30,7 +30,7 @@ public class PDOMIndexerJob extends Job {
* Job updating the progress monitor of the indexer job.
*/
final class ProgressUpdateJob extends Job {
private boolean fStopped;
private boolean fCancelled;
private ProgressUpdateJob() {
super(CCorePlugin.getResourceString("PDOMIndexerJob.updateMonitorJob")); //$NON-NLS-1$
@ -40,16 +40,28 @@ public class PDOMIndexerJob extends Job {
@Override
protected IStatus run(IProgressMonitor m) {
int currentTick= 0;
while (!fStopped && !m.isCanceled()) {
while (!fCancelled && !m.isCanceled()) {
currentTick= pdomManager.getMonitorMessage(PDOMIndexerJob.this, currentTick, TOTAL_MONITOR_WORK);
try {
Thread.sleep(PROGRESS_UPDATE_INTERVAL);
synchronized(this) {
if (fCancelled)
break;
wait(PROGRESS_UPDATE_INTERVAL);
}
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
@Override
protected void canceling() {
// Speed up cancellation by notifying the waiting thread.
synchronized(this) {
fCancelled= true;
notify();
}
}
}
private static final int PROGRESS_UPDATE_INTERVAL = 500;
@ -59,7 +71,7 @@ public class PDOMIndexerJob extends Job {
private final PDOMManager pdomManager;
private IPDOMIndexerTask currentTask;
private boolean cancelledByManager= false;
private Object taskMutex = new Object();
private final Object taskMutex = new Object();
private IProgressMonitor fMonitor;
private final boolean fShowActivity;