private BaseDataReader.SleepingPolicy getPolicy() { if (useNonBlockingRead()) { return useAdaptiveSleepingPolicyWhenReadingOutput() ? new AdaptiveSleepingPolicy() : BaseDataReader.SleepingPolicy.SIMPLE; } else { //use blocking read policy return BaseDataReader.SleepingPolicy.BLOCKING; } }
@Override public void startNotify() { // Wait for both the stdout and stderr reader threads to finish and then indicate that the process has terminated addProcessListener(new ProcessAdapter() { @Override public void startNotified(final ProcessEvent event) { try { final BaseDataReader stdoutReader = new EmulatorOutputReader(myProcess.getInputStream(), ProcessOutputTypes.STDOUT); final BaseDataReader stderrReader = new EmulatorOutputReader(myProcess.getErrorStream(), ProcessOutputTypes.STDERR); executeTask(new Runnable() { @Override public void run() { try { stderrReader.waitFor(); stdoutReader.waitFor(); } catch (InterruptedException ignore) { } finally { notifyProcessTerminated(0); } } }); } finally { removeProcessListener(this); } } }); super.startNotify(); }
private EmulatorOutputReader(@NotNull InputStream stream, @NotNull Key processOutputType) { super(BaseDataReader.SleepingPolicy.SIMPLE); // TODO: charset for the input stream reader? myBufferedReader = new BufferedReader(new InputStreamReader(stream)); myProcessOutputType = processOutputType; start(); }
@NotNull @Override protected BaseDataReader createOutputDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) { if (myForceBinary) { return new SimpleBinaryOutputReader(myProcess.getInputStream(), sleepingPolicy); } return super.createOutputDataReader(sleepingPolicy); }
@NotNull @Override protected BaseDataReader createOutputDataReader(@NotNull final BaseDataReader.SleepingPolicy sleepingPolicy) { myOutputReader = super.createProcessOutReader(); return new TheRXBaseOutputReader(myOutputReader, sleepingPolicy, myOutputBuffer, "output stream of " + myCommandLine); }
@NotNull @Override protected BaseDataReader createErrorDataReader(@NotNull final BaseDataReader.SleepingPolicy sleepingPolicy) { myErrorReader = super.createProcessErrReader(); return new TheRXBaseOutputReader(myErrorReader, sleepingPolicy, myErrorBuffer, "error stream of " + myCommandLine); }
@Override public void startNotify() { if (myCommandLine != null) { notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM); } addProcessListener(new ProcessAdapter() { @Override public void startNotified(final ProcessEvent event) { try { final BaseDataReader stdOutReader = createOutputDataReader(getPolicy()); final BaseDataReader stdErrReader = processHasSeparateErrorStream() ? createErrorDataReader(getPolicy()) : null; myWaitFor.setTerminationCallback(new Consumer<Integer>() { @Override public void consume(Integer exitCode) { try { // tell readers that no more attempts to read process' output should be made if (stdErrReader != null) stdErrReader.stop(); stdOutReader.stop(); try { if (stdErrReader != null) stdErrReader.waitFor(); stdOutReader.waitFor(); } catch (InterruptedException ignore) { } } finally { onOSProcessTerminated(exitCode); } } }); } finally { removeProcessListener(this); } } }); super.startNotify(); }
@NotNull protected BaseDataReader createErrorDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) { return new SimpleOutputReader(createProcessErrReader(), ProcessOutputTypes.STDERR, sleepingPolicy); }
@NotNull protected BaseDataReader createOutputDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) { return new SimpleOutputReader(createProcessOutReader(), ProcessOutputTypes.STDOUT, sleepingPolicy); }
@NotNull @Override protected BaseDataReader createOutputDataReader(BaseDataReader.SleepingPolicy sleepingPolicy) { return myBinary ? new MyBinaryOutputReader(myProcess.getInputStream(), sleepingPolicy) : super.createOutputDataReader(sleepingPolicy); }
public MyBinaryOutputReader(@NotNull InputStream stream, @Nullable BaseDataReader.SleepingPolicy simple) { super(stream, simple); start(); }
@Nonnull @Override protected BaseDataReader createOutputDataReader() { return new SimpleBinaryReader(myProcess.getInputStream(), readerOptions().policy()); }
@Override public BaseDataReader.SleepingPolicy policy() { return new BaseDataReader.AdaptiveSleepingPolicy(); }
@Override public void startNotify() { if (myCommandLine != null) { notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM); } addProcessListener(new ProcessAdapter() { @Override public void startNotified(final ProcessEvent event) { try { Options options = readerOptions(); @SuppressWarnings("deprecation") final BaseDataReader stdOutReader = createOutputDataReader(options.policy()); @SuppressWarnings("deprecation") final BaseDataReader stdErrReader = processHasSeparateErrorStream() ? createErrorDataReader(options.policy()) : null; myWaitFor.setTerminationCallback(new Consumer<Integer>() { @Override public void consume(Integer exitCode) { try { // tell readers that no more attempts to read process' output should be made if (stdErrReader != null) stdErrReader.stop(); stdOutReader.stop(); try { if (stdErrReader != null) stdErrReader.waitFor(); stdOutReader.waitFor(); } catch (InterruptedException ignore) { } } finally { onOSProcessTerminated(exitCode); } } }); } finally { removeProcessListener(this); } } }); super.startNotify(); }
/** @deprecated override {@link #createOutputDataReader()} (to be removed in IDEA 18) */ protected BaseDataReader createErrorDataReader(@SuppressWarnings("UnusedParameters") BaseDataReader.SleepingPolicy policy) { return createErrorDataReader(); }
/** @deprecated override {@link #createOutputDataReader()} (to be removed in IDEA 18) */ protected BaseDataReader createOutputDataReader(@SuppressWarnings("UnusedParameters") BaseDataReader.SleepingPolicy policy) { return createOutputDataReader(); }
@Nonnull protected BaseDataReader createErrorDataReader() { return new SimpleOutputReader(createProcessErrReader(), ProcessOutputTypes.STDERR, readerOptions(), "error stream of " + myPresentableName); }
@Nonnull protected BaseDataReader createOutputDataReader() { return new SimpleOutputReader(createProcessOutReader(), ProcessOutputTypes.STDOUT, readerOptions(), "output stream of " + myPresentableName); }