corda/classpath/java/lang/ref/ReferenceQueue.java

29 lines
536 B
Java
Raw Normal View History

2007-07-20 00:18:47 +00:00
package java.lang.ref;
public class ReferenceQueue<T> {
2007-07-20 00:18:47 +00:00
private Reference<? extends T> front;
private Reference<? extends T> rear;
public Reference<? extends T> poll() {
Reference<? extends T> r = front;
if (front != null) {
if (front == front.next) {
front = rear = null;
} else {
front = front.next;
}
}
return r;
}
void add(Reference<? extends T> r) {
r.next = r;
if (front == null) {
2007-07-20 01:07:30 +00:00
front = r;
2007-07-20 00:18:47 +00:00
} else {
rear.next = r;
}
2007-07-20 01:07:30 +00:00
rear = r;
2007-07-20 00:18:47 +00:00
}
}