James Moger
2014-02-22 924c9b28edfda6582a5480a7c1a2dd5b3ce89d92
src/main/java/com/gitblit/utils/WorkQueue.java
@@ -14,11 +14,6 @@
package com.gitblit.utils;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.ArrayList;
import java.util.Collection;
@@ -38,7 +33,10 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
/** Delayed execution of tasks using a background thread pool. */
public class WorkQueue {
@@ -55,7 +53,6 @@
  private final IdGenerator idGenerator;
  private final CopyOnWriteArrayList<Executor> queues;
  @Inject
  public WorkQueue(final IdGenerator idGenerator) {
    this.idGenerator = idGenerator;
    this.queues = new CopyOnWriteArrayList<Executor>();
@@ -268,6 +265,7 @@
      return startTime;
    }
    @Override
    public boolean cancel(boolean mayInterruptIfRunning) {
      if (task.cancel(mayInterruptIfRunning)) {
        // Tiny abuse of running: if the task needs to know it was
@@ -289,35 +287,43 @@
      }
    }
    @Override
    public int compareTo(Delayed o) {
      return task.compareTo(o);
    }
    @Override
    public V get() throws InterruptedException, ExecutionException {
      return task.get();
    }
    @Override
    public V get(long timeout, TimeUnit unit) throws InterruptedException,
        ExecutionException, TimeoutException {
      return task.get(timeout, unit);
    }
    @Override
    public long getDelay(TimeUnit unit) {
      return task.getDelay(unit);
    }
    @Override
    public boolean isCancelled() {
      return task.isCancelled();
    }
    @Override
    public boolean isDone() {
      return task.isDone();
    }
    @Override
    public boolean isPeriodic() {
      return task.isPeriodic();
    }
    @Override
    public void run() {
      if (running.compareAndSet(false, true)) {
        try {