aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-07-25 06:32:09 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-25 06:33:54 -0700
commit466121931913107f9ecbd1c7b96854d1d1d6d405 (patch)
tree5656c8fb463243e8abe3cdd9c7ed022da4cf8532
parent54a381b2bca74988c01b7e4bb7cf4c3e1507ac14 (diff)
Remove AbstractQueueVisitor.runConcurrently and .activeParallelTasks which
aren't used anymore. RELNOTES: None. PiperOrigin-RevId: 205984908
-rw-r--r--src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java54
-rw-r--r--src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java1
2 files changed, 17 insertions, 38 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java b/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
index 6b6c07517d..c4e526ba97 100644
--- a/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
+++ b/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java
@@ -218,47 +218,27 @@ public class AbstractQueueVisitor implements QuiescingExecutor {
/** Schedules a call. Called in a worker thread. */
@Override
public final void execute(Runnable runnable) {
- if (runConcurrently()) {
- WrappedRunnable wrappedRunnable = new WrappedRunnable(runnable);
- try {
- // It's impossible for this increment to result in remainingTasks.get <= 0 because
- // remainingTasks is never negative. Therefore it isn't necessary to check its value for
- // the purpose of updating zeroRemainingTasks.
- long tasks = remainingTasks.incrementAndGet();
- Preconditions.checkState(
- tasks > 0,
- "Incrementing remaining tasks counter resulted in impossible non-positive number.");
- executeRunnable(wrappedRunnable);
- } catch (Throwable e) {
- if (!wrappedRunnable.ran) {
- // Note that keeping track of ranTask is necessary to disambiguate the case where
- // execute() itself failed, vs. a caller-runs policy on pool exhaustion, where the
- // runnable threw. To be extra cautious, we decrement the task count in a finally
- // block, even though the CountDownLatch is unlikely to throw.
- recordError(e);
- }
+ WrappedRunnable wrappedRunnable = new WrappedRunnable(runnable);
+ try {
+ // It's impossible for this increment to result in remainingTasks.get <= 0 because
+ // remainingTasks is never negative. Therefore it isn't necessary to check its value for
+ // the purpose of updating zeroRemainingTasks.
+ long tasks = remainingTasks.incrementAndGet();
+ Preconditions.checkState(
+ tasks > 0,
+ "Incrementing remaining tasks counter resulted in impossible non-positive number.");
+ executeRunnable(wrappedRunnable);
+ } catch (Throwable e) {
+ if (!wrappedRunnable.ran) {
+ // Note that keeping track of ranTask is necessary to disambiguate the case where
+ // execute() itself failed, vs. a caller-runs policy on pool exhaustion, where the
+ // runnable threw. To be extra cautious, we decrement the task count in a finally
+ // block, even though the CountDownLatch is unlikely to throw.
+ recordError(e);
}
- } else {
- runnable.run();
}
}
- /**
- * Subclasses may override this to make dynamic decisions about whether to run tasks
- * asynchronously versus in-thread.
- */
- protected boolean runConcurrently() {
- return true;
- }
-
- /**
- * Returns an approximate count of how many threads in the queue visitor's thread pool are
- * occupied with tasks.
- */
- protected final int activeParallelTasks() {
- return jobs.size();
- }
-
protected void executeRunnable(Runnable runnable) {
executorService.execute(runnable);
}
diff --git a/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java b/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
index 108f18d866..070011b0d9 100644
--- a/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
@@ -50,7 +50,6 @@ public class AbstractQueueVisitorTest {
counter.enqueue();
counter.awaitQuiescence(/*interruptWorkers=*/ false);
assertThat(counter.getCount()).isSameAs(10);
- assertThat(counter.activeParallelTasks()).isSameAs(0);
}
@Test