CPP-6325 Do not sleep in readAvailableBlocking() for pty, things won't become better anyway

This commit is contained in:
Vyacheslav Karpukhin
2016-04-05 20:10:19 +02:00
parent a16f0b69b1
commit 6f0128e165
3 changed files with 18 additions and 6 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.util.io;
import com.pty4j.unix.PTYInputStream;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -42,4 +43,8 @@ public class BaseInputStreamReader extends InputStreamReader {
public void close() throws IOException {
myInputStream.close(); // close underlying input stream without locking in StreamDecoder.
}
public boolean availableUnsupported() {
return myInputStream instanceof PTYInputStream;
}
}
@@ -93,6 +93,7 @@ public abstract class BaseOutputReader extends BaseDataReader {
* @throws IOException If an I/O error occurs
*/
protected final boolean readAvailableBlocking() throws IOException {
final boolean availableUnsupported = ((BaseInputStreamReader)myReader).availableUnsupported();
boolean read = false;
int n;
@@ -101,14 +102,19 @@ public abstract class BaseOutputReader extends BaseDataReader {
read = true;
processLine(myInputBuffer, myLineBuffer, n);
}
if (!myReader.ready()) {
boolean isReady = availableUnsupported || myReader.ready();
if (!isReady) {
TimeoutUtil.sleep(mySleepingPolicy.getTimeToSleep(n > 0));
if (!myReader.ready()) {
if (myLineBuffer.length() > 0) {
sendLine(myLineBuffer);
}
onBufferExhaustion();
isReady = myReader.ready();
}
if (!isReady) {
if (myLineBuffer.length() > 0) {
sendLine(myLineBuffer);
}
onBufferExhaustion();
}
}
+1
View File
@@ -23,6 +23,7 @@
<orderEntry type="library" name="batik" level="project" />
<orderEntry type="library" name="xmlgraphics-commons" level="project" />
<orderEntry type="library" name="xml-apis-ext" level="project" />
<orderEntry type="library" name="pty4j" level="project" />
</component>
<component name="copyright">
<Base>