You are viewing a plain text version of this content. The canonical link for it is here.
Posted to droids-commits@incubator.apache.org by rf...@apache.org on 2012/04/12 22:17:09 UTC
svn commit: r1325550 -
/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java
Author: rfrovarp
Date: Thu Apr 12 22:17:08 2012
New Revision: 1325550
URL: http://svn.apache.org/viewvc?rev=1325550&view=rev
Log:
Fixes DROIDS-166.
Thanks to Tobias Ruebner for reporting and the patch.
Modified:
incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java
Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java?rev=1325550&r1=1325549&r2=1325550&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/impl/SimpleTaskQueueWithHistory.java Thu Apr 12 22:17:08 2012
@@ -19,57 +19,51 @@ package org.apache.droids.impl;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.LinkedList;
+import java.util.concurrent.LinkedBlockingQueue;
import org.apache.droids.api.Task;
/**
* Extend the task queue to ignore any tasks we have already seen
*/
-public class SimpleTaskQueueWithHistory<T extends Task> extends LinkedList<T>
-{
+public class SimpleTaskQueueWithHistory<T extends Task> extends LinkedBlockingQueue<T> {
private final java.util.Set<String> previous;
/**
* Simple queue constructor.
*/
- public SimpleTaskQueueWithHistory()
- {
+ public SimpleTaskQueueWithHistory() {
super();
previous = Collections.synchronizedSet(new HashSet<String>());
}
@Override
- public boolean offer(T e)
- {
- return add(e);
- }
-
- @Override
- public boolean add(T e)
- {
+ public boolean offer(T e) {
if (previous.add(e.getId())) {
- return super.add(e);
+ return super.offer(e);
} else {
return false;
}
}
@Override
- public boolean addAll(Collection<? extends T> c)
- {
+ public boolean add(T e) {
+ return this.offer(e);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends T> c) {
boolean hasChanged = false;
for (T e : c) {
// Must be in this order otherwise the short circuiting or
// will make it so that items aren't added.
- hasChanged = this.add(e) || hasChanged;
+ hasChanged = this.offer(e) || hasChanged;
}
return hasChanged;
}
- public void clearHistory()
- {
+ public void clearHistory() {
previous.clear();
}
}