mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for bug 61332 - make sure that the timer is ready to go before starting a new index
This commit is contained in:
parent
45ce2c7bd9
commit
14804f770c
3 changed files with 38 additions and 32 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-05-16 Bogdan Gheorghe
|
||||
Fix for bug 61332 - make sure that the timer is ready to go before starting
|
||||
a new index
|
||||
|
||||
2004-05-07 Bogdan Gheorghe
|
||||
Modified indexer friend encoding to encode IASTElaboratedTypeSpecifier
|
||||
|
||||
|
|
|
@ -614,6 +614,15 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
|||
*/
|
||||
public void startTimer() {
|
||||
createProgressMonitor();
|
||||
while (!timeoutThread.isReadyToRun()){
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
timeoutThread.startTimer();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.utils;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
|
@ -25,10 +26,10 @@ public class TimeOut implements Runnable {
|
|||
protected boolean enabled;
|
||||
protected IProgressMonitor pm = null;
|
||||
private int timeout = 0;
|
||||
// long timerTime=0;
|
||||
private int threadPriority = Thread.MIN_PRIORITY + 1;
|
||||
boolean debug = false;
|
||||
private String threadName = null;
|
||||
boolean readyToRun = true;
|
||||
|
||||
public TimeOut(){
|
||||
reset();
|
||||
|
@ -41,34 +42,24 @@ public class TimeOut implements Runnable {
|
|||
|
||||
public void run() {
|
||||
while (this.thread != null) {
|
||||
try {
|
||||
// System.out.println("Main loop: TOP time: " + (System.currentTimeMillis() - timerTime));
|
||||
if (enabled){
|
||||
// System.out.println("Main loop: ENABLED");
|
||||
synchronized (this){
|
||||
// System.out.println("Main loop: TIMEOUT START : waiting " + timeout + " ms");
|
||||
wait(timeout);
|
||||
// System.out.println("Main loop: TIMEOUT END");
|
||||
}
|
||||
if (enabled){
|
||||
// System.out.println("Main loop: ABOUT TO CANCEL");
|
||||
if(pm != null)
|
||||
pm.setCanceled(true);
|
||||
enabled = false;
|
||||
try {
|
||||
synchronized(this){
|
||||
if (enabled){
|
||||
readyToRun = false;
|
||||
wait(timeout);
|
||||
if (enabled){
|
||||
if(pm != null)
|
||||
pm.setCanceled(true);
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
// System.out.println("Main loop: NOT ENABLED");
|
||||
synchronized(this){
|
||||
while(!enabled){
|
||||
// System.out.println("SLEEP NOT ENABLED LOOP");
|
||||
wait();
|
||||
// timerTime = System.currentTimeMillis();
|
||||
// System.out.println("WOKE UP: enabled = " + enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
while(!enabled){
|
||||
readyToRun = true;
|
||||
wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -77,13 +68,11 @@ public class TimeOut implements Runnable {
|
|||
}
|
||||
|
||||
public synchronized void startTimer(){
|
||||
// System.out.println("START TIMER");
|
||||
enabled = true;
|
||||
notify();
|
||||
enabled = true;
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void stopTimer(){
|
||||
// System.out.println("STOP TIMER");
|
||||
enabled= false;
|
||||
notify();
|
||||
}
|
||||
|
@ -138,4 +127,8 @@ public class TimeOut implements Runnable {
|
|||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public boolean isReadyToRun(){
|
||||
return readyToRun;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue