Skip to content

Commit

Permalink
Refactor SkyframeActionExecutor
Browse files Browse the repository at this point in the history
- avoid FutureTask; make ActionRunner self-contained
- reorganize the prepare/execute/complete flow

This is in preparation for making actions async, which requires that
ActionRunner itself becomes async, which in turn precludes the use of
FutureTask and also requires that the code flow more cleanly separates
pre-execution and post-execution steps.

PiperOrigin-RevId: 220266937
  • Loading branch information
ulfjack authored and Copybara-Service committed Nov 6, 2018
1 parent 5f436f3 commit 14f8b10
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public final class ActionExecutionStatusReporter {
private static final int MAX_LINES = 10;

private final EventHandler eventHandler;
private final Executor executor;
private final EventBus eventBus;
private final Clock clock;

Expand All @@ -65,29 +64,29 @@ public static ActionExecutionStatusReporter create(EventHandler eventHandler) {
}

@VisibleForTesting
static ActionExecutionStatusReporter create(EventHandler eventHandler, Clock clock) {
return create(eventHandler, null, null, clock);
static ActionExecutionStatusReporter create(EventHandler eventHandler, @Nullable Clock clock) {
return create(eventHandler, null, clock);
}

public static ActionExecutionStatusReporter create(EventHandler eventHandler,
@Nullable Executor executor, @Nullable EventBus eventBus) {
return create(eventHandler, executor, eventBus, null);
public static ActionExecutionStatusReporter create(
EventHandler eventHandler, @Nullable EventBus eventBus) {
return create(eventHandler, eventBus, null);
}

private static ActionExecutionStatusReporter create(EventHandler eventHandler,
@Nullable Executor executor, @Nullable EventBus eventBus, @Nullable Clock clock) {
ActionExecutionStatusReporter result = new ActionExecutionStatusReporter(eventHandler, executor,
eventBus, clock == null ? BlazeClock.instance() : clock);
private static ActionExecutionStatusReporter create(
EventHandler eventHandler, @Nullable EventBus eventBus, @Nullable Clock clock) {
ActionExecutionStatusReporter result =
new ActionExecutionStatusReporter(
eventHandler, eventBus, clock == null ? BlazeClock.instance() : clock);
if (eventBus != null) {
eventBus.register(result);
}
return result;
}

private ActionExecutionStatusReporter(EventHandler eventHandler, @Nullable Executor executor,
@Nullable EventBus eventBus, Clock clock) {
private ActionExecutionStatusReporter(
EventHandler eventHandler, @Nullable EventBus eventBus, Clock clock) {
this.eventHandler = Preconditions.checkNotNull(eventHandler);
this.executor = executor;
this.eventBus = eventBus;
this.clock = Preconditions.checkNotNull(clock);
}
Expand All @@ -109,13 +108,6 @@ public void remove(Action action) {
Preconditions.checkNotNull(actionStatus.remove(action), action);
}

/**
* Set "Preparing" status.
*/
public void setPreparing(Action action) {
updateStatus(ActionStatusMessage.preparingStrategy(action));
}

@Subscribe
public void updateStatus(ActionStatusMessage statusMsg) {
String message = statusMsg.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public void buildArtifacts(
List<ExitCode> exitCodes = new LinkedList<>();
EvaluationResult<?> result;

ActionExecutionStatusReporter statusReporter = ActionExecutionStatusReporter.create(
reporter, executor, skyframeExecutor.getEventBus());
ActionExecutionStatusReporter statusReporter =
ActionExecutionStatusReporter.create(reporter, skyframeExecutor.getEventBus());

AtomicBoolean isBuildingExclusiveArtifacts = new AtomicBoolean(false);
ActionExecutionInactivityWatchdog watchdog =
Expand Down
Loading

0 comments on commit 14f8b10

Please sign in to comment.