This commit is contained in:
Alexey Kudravtsev
2012-03-06 12:44:48 +04:00
parent fb250ef886
commit 5bf826ebf0
3 changed files with 20 additions and 3 deletions
@@ -68,7 +68,6 @@ public class OSProcessHandler extends BaseOSProcessHandler {
/**
* Kill whole process tree.
* @param process Process
* @param forceKill If failed to kill process tree - try to kill it using Java API
* @return True if process tree has been successfully killed.
*/
protected boolean killProcessTree(final Process process) {
@@ -46,10 +46,10 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
private volatile boolean myFlushing;
private String myName;
private final String myName;
private int myMergingTimeSpan;
private JComponent myModalityStateComponent;
private boolean myExecuteInDispatchThread;
private final boolean myExecuteInDispatchThread;
private boolean myPassThrough;
private boolean myDisposed;
@@ -163,6 +163,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
restartTimer();
}
@Override
public void hideNotify() {
if (!myActive) {
return;
@@ -175,6 +176,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
clearWaiter();
}
@Override
public void showNotify() {
if (myActive) {
return;
@@ -202,6 +204,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
}
}
@Override
public void run() {
if (mySuspended) return;
flush();
@@ -227,6 +230,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
myFlushing = true;
final Runnable toRun = new Runnable() {
@Override
public void run() {
try {
final Update[] all;
@@ -289,6 +293,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
if (each.executeInWriteAction()) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
execute(each);
}
@@ -381,6 +386,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
return myActive;
}
@Override
public void dispose() {
myDisposed = true;
myActive = false;
@@ -51,19 +51,23 @@ public class BaseOSProcessHandler extends ProcessHandler {
return ExecutorServiceHolder.ourThreadExecutorsService.submit(task);
}
@NotNull
public Process getProcess() {
return myProcess;
}
@Override
public void startNotify() {
if (myCommandLine != null) {
notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM);
}
addProcessListener(new ProcessAdapter() {
@Override
public void startNotified(final ProcessEvent event) {
try {
final OutputReader stdoutReader = new OutputReader(createProcessOutReader()) {
@Override
protected void onTextAvailable(@NotNull String text) {
notifyTextAvailable(text, ProcessOutputTypes.STDOUT);
}
@@ -75,6 +79,7 @@ public class BaseOSProcessHandler extends ProcessHandler {
};
final OutputReader stderrReader = new OutputReader(createProcessErrReader()) {
@Override
protected void onTextAvailable(@NotNull String text) {
notifyTextAvailable(text, ProcessOutputTypes.STDERR);
}
@@ -135,6 +140,7 @@ public class BaseOSProcessHandler extends ProcessHandler {
return new InputStreamReader(streamToRead, charset);
}
@Override
protected void destroyProcessImpl() {
try {
closeStreams();
@@ -148,8 +154,10 @@ public class BaseOSProcessHandler extends ProcessHandler {
getProcess().destroy();
}
@Override
protected void detachProcessImpl() {
final Runnable runnable = new Runnable() {
@Override
public void run() {
closeStreams();
@@ -170,10 +178,12 @@ public class BaseOSProcessHandler extends ProcessHandler {
}
}
@Override
public boolean detachIsDefault() {
return false;
}
@Override
public OutputStream getProcessInput() {
return myProcess.getOutputStream();
}
@@ -194,6 +204,7 @@ public class BaseOSProcessHandler extends ProcessHandler {
private static ThreadPoolExecutor createServiceImpl() {
return new ThreadPoolExecutor(10, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() {
@Override
@SuppressWarnings({"HardCodedStringLiteral"})
public Thread newThread(Runnable r) {
return new Thread(r, "OSProcessHandler pooled thread");
@@ -213,6 +224,7 @@ public class BaseOSProcessHandler extends ProcessHandler {
public ProcessWaitFor(final Process process) {
myWaitForThreadFuture = executeOnPooledThread(new Runnable() {
@Override
public void run() {
int exitCode = 0;
try {