aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/worker/Worker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/worker/Worker.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/worker/Worker.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/worker/Worker.java b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
index 55705f4485..1cbd077e81 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/Worker.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
@@ -24,6 +24,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
/**
@@ -54,17 +56,15 @@ class Worker {
final Worker self = this;
this.shutdownHook =
- new Thread() {
- @Override
- public void run() {
- try {
- self.shutdownHook = null;
- self.destroy();
- } catch (IOException e) {
- // We can't do anything here.
- }
- }
- };
+ new Thread(
+ () -> {
+ try {
+ self.shutdownHook = null;
+ self.destroy();
+ } catch (IOException e) {
+ // We can't do anything here.
+ }
+ });
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
@@ -80,7 +80,6 @@ class Worker {
processBuilder.setWorkingDirectory(workDir.getPathFile());
processBuilder.setStderr(logFile.getPathFile());
processBuilder.setEnv(workerKey.getEnv());
-
this.process = processBuilder.start();
}
@@ -138,12 +137,7 @@ class Worker {
boolean isAlive() {
// This is horrible, but Process.isAlive() is only available from Java 8 on and this is the
// best we can do prior to that.
- try {
- process.exitValue();
- return false;
- } catch (IllegalThreadStateException e) {
- return true;
- }
+ return !process.finished();
}
InputStream getInputStream() {
@@ -154,9 +148,17 @@ class Worker {
return process.getOutputStream();
}
- public void prepareExecution(WorkerKey key) throws IOException {}
+ public void prepareExecution(
+ Map<PathFragment, Path> inputFiles,
+ Set<PathFragment> outputFiles,
+ Set<PathFragment> workerFiles)
+ throws IOException {
+ if (process == null) {
+ createProcess();
+ }
+ }
- public void finishExecution(WorkerKey key) throws IOException {}
+ public void finishExecution(Path execRoot) throws IOException {}
public Path getLogFile() {
return logFile;