summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/utils/WorkQueue.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-02-22 16:19:03 -0500
committerJames Moger <james.moger@gitblit.com>2014-04-10 18:58:07 -0400
commit924c9b28edfda6582a5480a7c1a2dd5b3ce89d92 (patch)
treec7320fcbe678a622aeca0047135f5faca58ea093 /src/main/java/com/gitblit/utils/WorkQueue.java
parentaf816d3fdd18d6d7d1b2c854b70eb30be789d466 (diff)
downloadgitblit-924c9b28edfda6582a5480a7c1a2dd5b3ce89d92.tar.gz
gitblit-924c9b28edfda6582a5480a7c1a2dd5b3ce89d92.zip
Eliminate use of Dagger and do not create inner classes
This change outlines somethings I'd like to see in your latest code. 1. Elimination of Dagger 2. Less noise from inner class instantiation 3. Formalizing filesystem location for keys instead of Unix-y /tmp/ 4. Password authentication as alternative to Key authentication Change-Id: I7a76e1811ad7cd545444fd8b59bbe8c4f45ccfec
Diffstat (limited to 'src/main/java/com/gitblit/utils/WorkQueue.java')
-rw-r--r--src/main/java/com/gitblit/utils/WorkQueue.java38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/main/java/com/gitblit/utils/WorkQueue.java b/src/main/java/com/gitblit/utils/WorkQueue.java
index 778e754c..ba49a4c5 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.TimeoutException;
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 @@ public class WorkQueue {
private final IdGenerator idGenerator;
private final CopyOnWriteArrayList<Executor> queues;
- @Inject
public WorkQueue(final IdGenerator idGenerator) {
this.idGenerator = idGenerator;
this.queues = new CopyOnWriteArrayList<Executor>();
@@ -268,7 +265,8 @@ public class WorkQueue {
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 +287,44 @@ public class WorkQueue {
}
}
- 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();