本文整理匯總了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();
}
示例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();
}
};
}
示例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();
}
};
}
示例4: waitFor
import com.intellij.execution.process.ProcessHandler; //導入方法依賴的package包/類
protected boolean waitFor(ProcessHandler p) throws InterruptedException {
return p.waitFor(myTimeout);
}
示例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;
}