Java 类com.intellij.openapi.util.process.InterruptibleProcess 实例源码

项目:intellij-ce-playground    文件:ProcessWaiter.java   
public int execute(final InterruptibleProcess worker, final long timeout) throws IOException, ExecutionException, TimeoutException, InterruptedException {
  myErrStreamListener = createStreamListener(worker.getErrorStream());
  myInStreamListener = createStreamListener(worker.getInputStream());

  final Application app = ApplicationManager.getApplication();
  Future<?> errorStreamReadingFuture = null;
  Future<?> outputStreamReadingFuture = null;

  final int rc;
  try {
    errorStreamReadingFuture = app.executeOnPooledThread(myErrStreamListener);
    outputStreamReadingFuture = app.executeOnPooledThread(myInStreamListener);
    rc = worker.execute();
    if (tryReadStreams(rc)) {
      errorStreamReadingFuture.get(timeout, TimeUnit.MILLISECONDS);
      outputStreamReadingFuture.get(timeout, TimeUnit.MILLISECONDS);
    }
  } finally {
    cancelListeners();
    if (errorStreamReadingFuture != null) {
      errorStreamReadingFuture.cancel(true);
    }
    if (outputStreamReadingFuture != null) {
      outputStreamReadingFuture.cancel(true);
    }
  }

  return rc;
}
项目:tools-idea    文件:ProcessWaiter.java   
public int execute(final InterruptibleProcess worker, final long timeout) throws IOException, ExecutionException, TimeoutException, InterruptedException {
  myErrStreamListener = createStreamListener(worker.getErrorStream());
  myInStreamListener = createStreamListener(worker.getInputStream());

  final Application app = ApplicationManager.getApplication();
  Future<?> errorStreamReadingFuture = null;
  Future<?> outputStreamReadingFuture = null;

  final int rc;
  try {
    errorStreamReadingFuture = app.executeOnPooledThread(myErrStreamListener);
    outputStreamReadingFuture = app.executeOnPooledThread(myInStreamListener);
    rc = worker.execute();
    if (tryReadStreams(rc)) {
      errorStreamReadingFuture.get(timeout, TimeUnit.MILLISECONDS);
      outputStreamReadingFuture.get(timeout, TimeUnit.MILLISECONDS);
    }
  } finally {
    cancelListeners();
    if (errorStreamReadingFuture != null) {
      errorStreamReadingFuture.cancel(true);
    }
    if (outputStreamReadingFuture != null) {
      outputStreamReadingFuture.cancel(true);
    }
  }

  return rc;
}
项目:consulo    文件:ProcessWaiter.java   
public int execute(final InterruptibleProcess worker, final long timeout) throws IOException, ExecutionException, TimeoutException, InterruptedException {
  myErrStreamListener = createStreamListener(worker.getErrorStream());
  myInStreamListener = createStreamListener(worker.getInputStream());

  final Application app = ApplicationManager.getApplication();
  Future<?> errorStreamReadingFuture = null;
  Future<?> outputStreamReadingFuture = null;

  final int rc;
  try {
    errorStreamReadingFuture = app.executeOnPooledThread(myErrStreamListener);
    outputStreamReadingFuture = app.executeOnPooledThread(myInStreamListener);
    rc = worker.execute();
    if (tryReadStreams(rc)) {
      errorStreamReadingFuture.get(timeout, TimeUnit.MILLISECONDS);
      outputStreamReadingFuture.get(timeout, TimeUnit.MILLISECONDS);
    }
  } finally {
    cancelListeners();
    if (errorStreamReadingFuture != null) {
      errorStreamReadingFuture.cancel(true);
    }
    if (outputStreamReadingFuture != null) {
      outputStreamReadingFuture.cancel(true);
    }
  }

  return rc;
}