1
0
Fork 0
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:
Bogdan Gheorghe 2004-05-17 03:57:55 +00:00
parent 45ce2c7bd9
commit 14804f770c
3 changed files with 38 additions and 32 deletions

View file

@ -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 2004-05-07 Bogdan Gheorghe
Modified indexer friend encoding to encode IASTElaboratedTypeSpecifier Modified indexer friend encoding to encode IASTElaboratedTypeSpecifier

View file

@ -614,6 +614,15 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
*/ */
public void startTimer() { public void startTimer() {
createProgressMonitor(); createProgressMonitor();
while (!timeoutThread.isReadyToRun()){
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
timeoutThread.startTimer(); timeoutThread.startTimer();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -10,6 +10,7 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.utils; package org.eclipse.cdt.utils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
/** /**
@ -25,10 +26,10 @@ public class TimeOut implements Runnable {
protected boolean enabled; protected boolean enabled;
protected IProgressMonitor pm = null; protected IProgressMonitor pm = null;
private int timeout = 0; private int timeout = 0;
// long timerTime=0;
private int threadPriority = Thread.MIN_PRIORITY + 1; private int threadPriority = Thread.MIN_PRIORITY + 1;
boolean debug = false; boolean debug = false;
private String threadName = null; private String threadName = null;
boolean readyToRun = true;
public TimeOut(){ public TimeOut(){
reset(); reset();
@ -42,33 +43,23 @@ public class TimeOut implements Runnable {
public void run() { public void run() {
while (this.thread != null) { while (this.thread != null) {
try { try {
// System.out.println("Main loop: TOP time: " + (System.currentTimeMillis() - timerTime));
if (enabled){
// System.out.println("Main loop: ENABLED");
synchronized(this){ synchronized(this){
// System.out.println("Main loop: TIMEOUT START : waiting " + timeout + " ms");
wait(timeout);
// System.out.println("Main loop: TIMEOUT END");
}
if (enabled){ if (enabled){
// System.out.println("Main loop: ABOUT TO CANCEL"); readyToRun = false;
wait(timeout);
if (enabled){
if(pm != null) if(pm != null)
pm.setCanceled(true); pm.setCanceled(true);
enabled = false; enabled = false;
} }
} }
else{ else{
// System.out.println("Main loop: NOT ENABLED");
synchronized(this){
while(!enabled){ while(!enabled){
// System.out.println("SLEEP NOT ENABLED LOOP"); readyToRun = true;
wait(); wait();
// timerTime = System.currentTimeMillis();
// System.out.println("WOKE UP: enabled = " + enabled);
} }
} }
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -77,13 +68,11 @@ public class TimeOut implements Runnable {
} }
public synchronized void startTimer(){ public synchronized void startTimer(){
// System.out.println("START TIMER");
enabled = true; enabled = true;
notify(); notify();
} }
public synchronized void stopTimer(){ public synchronized void stopTimer(){
// System.out.println("STOP TIMER");
enabled= false; enabled= false;
notify(); notify();
} }
@ -138,4 +127,8 @@ public class TimeOut implements Runnable {
public void setTimeout(int timeout) { public void setTimeout(int timeout) {
this.timeout = timeout; this.timeout = timeout;
} }
public boolean isReadyToRun(){
return readyToRun;
}
} }