当前位置: 首页>>代码示例>>Java>>正文


Java ProcessHandler.waitFor方法代码示例

本文整理汇总了Java中com.intellij.execution.process.ProcessHandler.waitFor方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessHandler.waitFor方法的具体用法?Java ProcessHandler.waitFor怎么用?Java ProcessHandler.waitFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.execution.process.ProcessHandler的用法示例。


在下文中一共展示了ProcessHandler.waitFor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitProcess

import com.intellij.execution.process.ProcessHandler; //导入方法依赖的package包/类
public void waitProcess(final ProcessHandler processHandler) {
  Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, getTestRootDisposable());

  final boolean[] isRunning = {true};
  alarm.addRequest(new Runnable() {
    @Override
    public void run() {
      boolean b;
      synchronized (isRunning) {
        b = isRunning[0];
      }
      if (b) {
        processHandler.destroyProcess();
        LOG.error("process was running over " + myTimeout / 1000 + " seconds. Interrupted. ");
      }
    }
  }, myTimeout);
  processHandler.waitFor();
  synchronized (isRunning) {
    isRunning[0] = false;
  }
  alarm.dispose();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ExecutionTestCase.java

示例2: createTimeLimitedExecutionProcess

import com.intellij.execution.process.ProcessHandler; //导入方法依赖的package包/类
private static Runnable createTimeLimitedExecutionProcess(final ProcessHandler processHandler,
                                                          final ExecutionMode mode,
                                                          @NotNull final String presentableCmdline) {
  return new Runnable() {
    private final Semaphore mySemaphore = new Semaphore();

    private final Runnable myProcessThread = new Runnable() {
      @Override
      public void run() {
        try {
          final boolean finished = processHandler.waitFor(1000 * mode.getTimeout());
          if (!finished) {
            mode.getTimeoutCallback().consume(mode, presentableCmdline);
            processHandler.destroyProcess();
          }
        }
        finally {
          mySemaphore.up();
        }
      }
    };

    @Override
    public void run() {
      mySemaphore.down();
      ApplicationManager.getApplication().executeOnPooledThread(myProcessThread);

      mySemaphore.waitFor();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ExecutionHelper.java

示例3: createCancelableExecutionProcess

import com.intellij.execution.process.ProcessHandler; //导入方法依赖的package包/类
private static Runnable createCancelableExecutionProcess(final ProcessHandler processHandler,
                                                         final Function<Object, Boolean> cancelableFun) {
  return new Runnable() {
    private ProgressIndicator myProgressIndicator;
    private final Semaphore mySemaphore = new Semaphore();

    private final Runnable myWaitThread = new Runnable() {
      @Override
      public void run() {
        try {
          processHandler.waitFor();
        }
        finally {
          mySemaphore.up();
        }
      }
    };

    private final Runnable myCancelListener = new Runnable() {
      @Override
      public void run() {
        while (true) {
          if ((myProgressIndicator != null && (myProgressIndicator.isCanceled()
                                               || !myProgressIndicator.isRunning()))
              || (cancelableFun != null && cancelableFun.fun(null).booleanValue())
              || processHandler.isProcessTerminated()) {

            if (!processHandler.isProcessTerminated()) {
              try {
                processHandler.destroyProcess();
              }
              finally {
                mySemaphore.up();
              }
            }
            break;
          }
          try {
            synchronized (this) {
              wait(1000);
            }
          }
          catch (InterruptedException e) {
            //Do nothing
          }
        }
      }
    };

    @Override
    public void run() {
      myProgressIndicator = ProgressManager.getInstance().getProgressIndicator();
      if (myProgressIndicator != null && StringUtil.isEmpty(myProgressIndicator.getText())) {
        myProgressIndicator.setText("Please wait...");
      }

      LOG.assertTrue(myProgressIndicator != null || cancelableFun != null,
                     "Cancelable process must have an opportunity to be canceled!");
      mySemaphore.down();
      ApplicationManager.getApplication().executeOnPooledThread(myWaitThread);
      ApplicationManager.getApplication().executeOnPooledThread(myCancelListener);

      mySemaphore.waitFor();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:67,代码来源:ExecutionHelper.java

示例4: waitFor

import com.intellij.execution.process.ProcessHandler; //导入方法依赖的package包/类
protected boolean waitFor(ProcessHandler p) throws InterruptedException {
  return p.waitFor(myTimeout);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:PyExecutionFixtureTestTask.java

示例5: runGroovyc

import com.intellij.execution.process.ProcessHandler; //导入方法依赖的package包/类
@Override
public GroovycContinuation runGroovyc(Collection<String> compilationClassPath,
                                      boolean forStubs,
                                      JpsGroovySettings settings,
                                      File tempFile,
                                      final GroovycOutputParser parser)
  throws Exception {
  List<String> classpath = new ArrayList<String>();
  if (myOptimizeClassLoading) {
    classpath.addAll(GroovyBuilder.getGroovyRtRoots());
    classpath.add(ClasspathBootstrap.getResourcePath(Function.class));
    classpath.add(ClasspathBootstrap.getResourcePath(UrlClassLoader.class));
    classpath.add(ClasspathBootstrap.getResourceFile(THashMap.class).getPath());
  } else {
    classpath.addAll(compilationClassPath);
  }

  List<String> vmParams = ContainerUtilRt.newArrayList();
  vmParams.add("-Xmx" + System.getProperty("groovyc.heap.size", settings.heapSize) + "m");
  vmParams.add("-Dfile.encoding=" + System.getProperty("file.encoding"));
  //vmParams.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239");
  
  if ("false".equals(System.getProperty(GroovyRtConstants.GROOVYC_ASM_RESOLVING_ONLY))) {
    vmParams.add("-D" + GroovyRtConstants.GROOVYC_ASM_RESOLVING_ONLY + "=false");
  }
  String configScript = settings.configScript;
  if (StringUtil.isNotEmpty(configScript)) {
    vmParams.add("-D" + GroovyRtConstants.GROOVYC_CONFIG_SCRIPT + "=" + configScript);
  }

  String grapeRoot = System.getProperty(GroovycOutputParser.GRAPE_ROOT);
  if (grapeRoot != null) {
    vmParams.add("-D" + GroovycOutputParser.GRAPE_ROOT + "=" + grapeRoot);
  }

  final List<String> cmd = ExternalProcessUtil.buildJavaCommandLine(
    getJavaExecutable(myChunk),
    "org.jetbrains.groovy.compiler.rt.GroovycRunner",
    Collections.<String>emptyList(), classpath,
    vmParams,
    getProgramParams(tempFile, settings, forStubs)
  );
  final Process process = Runtime.getRuntime().exec(ArrayUtil.toStringArray(cmd));
  ProcessHandler handler = new BaseOSProcessHandler(process, null, null) {
    @Override
    protected Future<?> executeOnPooledThread(Runnable task) {
      return SharedThreadPool.getInstance().executeOnPooledThread(task);
    }

    @Override
    public void notifyTextAvailable(String text, Key outputType) {
      parser.notifyTextAvailable(text, outputType);
    }
  };

  handler.startNotify();
  handler.waitFor();
  parser.notifyFinished(process.exitValue());
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:61,代码来源:ForkedGroovyc.java


注:本文中的com.intellij.execution.process.ProcessHandler.waitFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。