Make CppLinkAction implement Action.execute() instead of beginExecution().
Another step towards removing the continuation-based action execution machinery.
RELNOTES: None.
@@ -22,9 +22,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.devtools.build.lib.actions.AbstractAction;
-import com.google.devtools.build.lib.actions.ActionContinuationOrResult;
import com.google.devtools.build.lib.actions.ActionEnvironment;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionExecutionException;
@@ -275,15 +273,22 @@ public final class CppLinkAction extends AbstractAction implements CommandAction
}
@Override
- @ThreadCompatible
- public ActionContinuationOrResult beginExecution(ActionExecutionContext actionExecutionContext)
+ public ActionResult execute(ActionExecutionContext actionExecutionContext)
throws ActionExecutionException, InterruptedException {
Spawn spawn = createSpawn(actionExecutionContext);
- SpawnContinuation spawnContinuation =
+ SpawnContinuation continuation =
actionExecutionContext
.getContext(SpawnStrategyResolver.class)
.beginExecution(spawn, actionExecutionContext);
- return new CppLinkActionContinuation(actionExecutionContext, spawnContinuation);
+
+ try {
+ while (!continuation.isDone()) {
+ continuation = continuation.execute();
+ }
+ return ActionResult.create(continuation.get());
+ } catch (ExecException e) {
+ throw ActionExecutionException.fromExecException(e, CppLinkAction.this);
+ }
}
private Spawn createSpawn(ActionExecutionContext actionExecutionContext)
@@ -428,36 +433,6 @@ public final class CppLinkAction extends AbstractAction implements CommandAction
}
}
- private final class CppLinkActionContinuation extends ActionContinuationOrResult {
- private final ActionExecutionContext actionExecutionContext;
- private final SpawnContinuation spawnContinuation;
-
- public CppLinkActionContinuation(
- ActionExecutionContext actionExecutionContext, SpawnContinuation spawnContinuation) {
- this.actionExecutionContext = actionExecutionContext;
- this.spawnContinuation = spawnContinuation;
- }
-
- @Override
- public ListenableFuture<?> getFuture() {
- return spawnContinuation.getFuture();
- }
-
- @Override
- public ActionContinuationOrResult execute()
- throws ActionExecutionException, InterruptedException {
- try {
- SpawnContinuation nextContinuation = spawnContinuation.execute();
- if (!nextContinuation.isDone()) {
- return new CppLinkActionContinuation(actionExecutionContext, nextContinuation);
- }
- return ActionContinuationOrResult.of(ActionResult.create(nextContinuation.get()));
- } catch (ExecException e) {
- throw ActionExecutionException.fromExecException(e, CppLinkAction.this);
- }
- }
- }
-
@Override
public Sequence<String> getStarlarkArgv() throws EvalException {
try {
