Backend refactoring: KjcEngine has been split up into separate classes for preprocessing, compiling, and running.

This commit is contained in:
dmose
2003-07-04 18:43:47 +00:00
parent 68d74da398
commit ec38155680
11 changed files with 1211 additions and 1302 deletions

View File

@@ -0,0 +1,57 @@
/// -*- Mode: JDE; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
import java.io.*;
// XXXdmose error checking
class PdeMessageSiphon implements Runnable {
BufferedReader stdout, stderr;
PrintStream leechErr;
Thread thread;
PdeMessageConsumer consumer;
public PdeMessageSiphon(InputStream stdout, InputStream stderr,
PdeMessageConsumer consumer) {
// XXXdmose error checking here
this.stdout = new BufferedReader(new InputStreamReader(stdout));
this.stderr = new BufferedReader(new InputStreamReader(stderr));
this.consumer = consumer;
thread = new Thread(this);
thread.start();
}
public void run() {
String currentLine;
while (Thread.currentThread() == thread) {
// XXX put back while loops
try {
if (stderr.ready()) {
currentLine = stderr.readLine();
System.err.println(currentLine);
consumer.message(currentLine);
}
if (stdout.ready()) {
currentLine = stdout.readLine();
System.err.println(currentLine);
consumer.message(currentLine);
}
Thread.sleep(10);
} catch (Exception e) {
System.err.println("PdeMessageSiphon err " + e);
thread.stop();
thread = null;
}
}
}
}