Java 类com.intellij.util.io.BaseOutputReader 实例源码

项目:tools-idea    文件:BaseOSProcessHandler.java   
@Override
public void startNotify() {
  if (myCommandLine != null) {
    notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM);
  }

  addProcessListener(new ProcessAdapter() {
    @Override
    public void startNotified(final ProcessEvent event) {
      try {
        BaseOutputReader.SleepingPolicy sleepingPolicy =
          useAdaptiveSleepingPolicyWhenReadingOutput() ? new AdaptiveSleepingPolicy() : BaseOutputReader.SleepingPolicy.SIMPLE;
        final BaseOutputReader stdoutReader = new SimpleOutputReader(createProcessOutReader(), ProcessOutputTypes.STDOUT, sleepingPolicy);
        final BaseOutputReader stderrReader = processHasSeparateErrorStream()
                                              ? new SimpleOutputReader(createProcessErrReader(), ProcessOutputTypes.STDERR,
                                                                       sleepingPolicy)
                                              : 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();
}
项目:consulo    文件:OSProcessHandler.java   
@Nonnull
@Override
protected BaseOutputReader.Options readerOptions() {
  return myHasPty ? BaseOutputReader.Options.BLOCKING : super.readerOptions();  // blocking read in case of PTY-based process
}
项目:consulo    文件:NativeFileWatcherImpl.java   
@Nonnull
@Override
protected BaseOutputReader.Options readerOptions() {
  return READER_OPTIONS;
}