From 6bd25df6bd0dfbc2e516ba5d392e7ba580b6eea9 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 03 Jul 2014 16:16:54 -0400
Subject: [PATCH] Switch apt folder from 'dagger' to 'gen'
---
src/main/java/com/gitblit/utils/WorkQueue.java | 44 ++++++++++++++++++++++++++------------------
1 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/gitblit/utils/WorkQueue.java b/src/main/java/com/gitblit/utils/WorkQueue.java
index 778e754..ce89d69 100644
--- a/src/main/java/com/gitblit/utils/WorkQueue.java
+++ b/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 {
@@ -53,18 +51,19 @@
private Executor defaultQueue;
private final IdGenerator idGenerator;
+ private final int defaultQueueSize;
private final CopyOnWriteArrayList<Executor> queues;
- @Inject
- public WorkQueue(final IdGenerator idGenerator) {
+ public WorkQueue(final IdGenerator idGenerator, final int defaultQueueSize) {
this.idGenerator = idGenerator;
+ this.defaultQueueSize = defaultQueueSize;
this.queues = new CopyOnWriteArrayList<Executor>();
}
/** Get the default work queue, for miscellaneous tasks. */
public synchronized Executor getDefaultQueue() {
if (defaultQueue == null) {
- defaultQueue = createQueue(1, "WorkQueue");
+ defaultQueue = createQueue(defaultQueueSize, "WorkQueue");
}
return defaultQueue;
}
@@ -268,7 +267,8 @@
return startTime;
}
- public boolean cancel(boolean mayInterruptIfRunning) {
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
if (task.cancel(mayInterruptIfRunning)) {
// Tiny abuse of running: if the task needs to know it was
// canceled (to clean up resources) and it hasn't started
@@ -289,36 +289,44 @@
}
}
- public int compareTo(Delayed o) {
+ @Override
+ public int compareTo(Delayed o) {
return task.compareTo(o);
}
- public V get() throws InterruptedException, ExecutionException {
+ @Override
+ public V get() throws InterruptedException, ExecutionException {
return task.get();
}
- public V get(long timeout, TimeUnit unit) throws InterruptedException,
+ @Override
+ public V get(long timeout, TimeUnit unit) throws InterruptedException,
ExecutionException, TimeoutException {
return task.get(timeout, unit);
}
- public long getDelay(TimeUnit unit) {
+ @Override
+ public long getDelay(TimeUnit unit) {
return task.getDelay(unit);
}
- public boolean isCancelled() {
+ @Override
+ public boolean isCancelled() {
return task.isCancelled();
}
- public boolean isDone() {
+ @Override
+ public boolean isDone() {
return task.isDone();
}
- public boolean isPeriodic() {
+ @Override
+ public boolean isPeriodic() {
return task.isPeriodic();
}
- public void run() {
+ @Override
+ public void run() {
if (running.compareAndSet(false, true)) {
try {
task.run();
--
Gitblit v1.9.1