提交 56f3a46f 编写于 作者: K kohsuke

natural place to do the ordering is in Item.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1981 71c3de6d-444a-0410-be80-ed276b4c234a
上级 08f4075a
......@@ -35,16 +35,6 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
*/
public class Queue {
private static final Comparator<Item> itemComparator = new Comparator<Item>() {
public int compare(Item lhs, Item rhs) {
int r = lhs.timestamp.getTime().compareTo(rhs.timestamp.getTime());
if(r!=0) return r;
return lhs.id-rhs.id;
}
};
/**
* Items in the queue ordered by {@link Item#timestamp}.
*
......@@ -52,7 +42,7 @@ public class Queue {
* This consists of {@link Item}s that cannot be run yet
* because its time has not yet come.
*/
private final Set<Item> queue = new TreeSet<Item>(itemComparator);
private final Set<Item> queue = new TreeSet<Item>();
/**
* {@link Project}s that can be built immediately
......@@ -434,7 +424,7 @@ public class Queue {
/**
* Item in a queue.
*/
public class Item {
public class Item implements Comparable<Item> {
/**
* This item can be run after this time.
*/
......@@ -517,6 +507,14 @@ public class Queue {
return "???";
}
public int compareTo(Item that) {
int r = this.timestamp.getTime().compareTo(that.timestamp.getTime());
if(r!=0) return r;
return this.id-that.id;
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册