1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 573110: Emulator can spin if Reader is ready but not available

The implementation of the read loop in the emulator can spin because
it uses Reader.ready() to determine if there is more data to read.

However the Reader contract does not specify that ready() means
that read() will return a character, simply it means that read()
won't block. As such, if a Reader won't block, but it has no
characters, the inner read loop will spin constantly polling.

The outer loop uses polling too - but it has a wait so that the
CPU does not hit 100% and yields.

Change-Id: Id9b2426c65e6c2a2c3ae817a78d2be435e568c1f
This commit is contained in:
Jonah Graham 2021-04-23 10:13:05 -04:00
parent 4ef3cb7f30
commit 327026010b

View file

@ -1515,9 +1515,10 @@ public class VT100Emulator implements ControlListener {
}
private boolean hasNextChar() throws IOException {
if (fNextChar >= 0)
return true;
return fReader.ready();
if (fNextChar < 0 && fReader.ready()) {
fNextChar = fReader.read();
}
return fNextChar >= 0;
}
/**