diff options
author | Mark Schaller <mschaller@google.com> | 2015-11-02 16:53:11 +0000 |
---|---|---|
committer | David Chen <dzc@google.com> | 2015-11-02 23:18:49 +0000 |
commit | 29375d405399a2d39b42c853849e39cb82048c19 (patch) | |
tree | 5bf386ac311d1c9e410eeeacb5b3509339b93db7 /src/main | |
parent | b92ff43bcb5653442e36b1d68403439b4ac65d33 (diff) |
Change ValueVisitor to use delegation
This simplifies a future change that introduces new variance to
ValueVisitor's use of AbstractQueueVisitor.
--
MOS_MIGRATED_REVID=106846210
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java index 4908fd629d..3c64b616e0 100644 --- a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java +++ b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java @@ -15,6 +15,7 @@ package com.google.devtools.build.skyframe; import static com.google.devtools.build.skyframe.SkyKeyInterner.SKY_KEY_INTERNER; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; @@ -610,25 +611,28 @@ public final class ParallelEvaluator implements Evaluator { } }; - private class ValueVisitor extends AbstractQueueVisitor { + private class ValueVisitor { + + private final AbstractQueueVisitor abstractQueueVisitor; private AtomicBoolean preventNewEvaluations = new AtomicBoolean(false); private final Set<SkyKey> inflightNodes = Sets.newConcurrentHashSet(); private final Set<RuntimeException> crashes = Sets.newConcurrentHashSet(); private ValueVisitor(int threadCount) { - super( - /*concurrent*/ true, - threadCount, - 1, - TimeUnit.SECONDS, - /*failFastOnException*/ true, - /*failFastOnInterrupt*/ true, - "skyframe-evaluator", - VALUE_VISITOR_ERROR_CLASSIFIER); + abstractQueueVisitor = + new AbstractQueueVisitor( + /*concurrent*/ true, + threadCount, + 1, + TimeUnit.SECONDS, + /*failFastOnException*/ true, + /*failFastOnInterrupt*/ true, + "skyframe-evaluator", + VALUE_VISITOR_ERROR_CLASSIFIER); } protected void waitForCompletion() throws InterruptedException { - awaitQuiescence(/*interruptWorkers=*/ true); + abstractQueueVisitor.awaitQuiescence(/*interruptWorkers=*/ true); } public void enqueueEvaluation(final SkyKey key) { @@ -649,7 +653,7 @@ public final class ParallelEvaluator implements Evaluator { if (newlyEnqueued && progressReceiver != null) { progressReceiver.enqueueing(key); } - execute(new Evaluate(this, key)); + abstractQueueVisitor.execute(new Evaluate(this, key)); } /** @@ -677,6 +681,11 @@ public final class ParallelEvaluator implements Evaluator { private boolean isInflight(SkyKey key) { return inflightNodes.contains(key); } + + @VisibleForTesting + public CountDownLatch getExceptionLatchForTestingOnly() { + return abstractQueueVisitor.getExceptionLatchForTestingOnly(); + } } /** |