Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-12-05 16:27:13 +0000
committerUwe Stieber2012-12-05 16:28:21 +0000
commit260cb135196b325c8b4f64de1b3ede5c0c3e713c (patch)
tree33fcca90637a615e65fdf4be363a3bc8a4757688 /target_explorer/plugins/org.eclipse.tcf.te.runtime
parentc34d956313090104af55fc27f6ad2ccd61de932f (diff)
downloadorg.eclipse.tcf-260cb135196b325c8b4f64de1b3ede5c0c3e713c.tar.gz
org.eclipse.tcf-260cb135196b325c8b4f64de1b3ede5c0c3e713c.tar.xz
org.eclipse.tcf-260cb135196b325c8b4f64de1b3ede5c0c3e713c.zip
Target Explorer: Added callback to ProcessWaiter to be invoked if the monitored process exited
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/processes/ProcessWaiter.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/processes/ProcessWaiter.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/processes/ProcessWaiter.java
index 110d4a3e2..53e4a6f2b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/processes/ProcessWaiter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/processes/ProcessWaiter.java
@@ -10,6 +10,8 @@
package org.eclipse.tcf.te.runtime.processes;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
/**
* A simple process waiter class. The process waiter keeps "running" till the observed process
@@ -18,6 +20,8 @@ import org.eclipse.core.runtime.Assert;
public class ProcessWaiter extends Thread {
// Reference to the process handle
private Process process;
+ // Reference to the callback to invoke
+ private ICallback callback;
// Flag set once the process finished
private boolean finished;
// The exit code of the process
@@ -29,10 +33,21 @@ public class ProcessWaiter extends Thread {
* @param process The process to monitor. Must not be <code>null</code>.
*/
public ProcessWaiter(final Process process) {
+ this(process, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param process The process to monitor. Must not be <code>null</code>.
+ * @param callback The callback to invoke once the process exit, or <code>null</code>.
+ */
+ public ProcessWaiter(final Process process, final ICallback callback) {
super();
Assert.isNotNull(process);
this.process = process;
+ this.callback = callback;
this.finished = false;
this.exitCode = -1;
}
@@ -49,6 +64,13 @@ public class ProcessWaiter extends Thread {
/* ignored on purpose */
}
finished = true;
+
+ // If there is a callback given, invoke the callback
+ // with the exit code set as result
+ if (callback != null) {
+ callback.setResult(Integer.valueOf(exitCode));
+ callback.done(this, Status.OK_STATUS);
+ }
}
/**

Back to the top