From 466121931913107f9ecbd1c7b96854d1d1d6d405 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 25 Jul 2018 06:32:09 -0700 Subject: Remove AbstractQueueVisitor.runConcurrently and .activeParallelTasks which aren't used anymore. RELNOTES: None. PiperOrigin-RevId: 205984908 --- .../build/lib/concurrent/AbstractQueueVisitor.java | 54 +++++++--------------- 1 file changed, 17 insertions(+), 37 deletions(-) (limited to 'src/main/java/com') 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); } -- cgit v1.2.3