mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
29 lines
554 B
Java
29 lines
554 B
Java
package java.lang.ref;
|
|
|
|
public abstract class ReferenceQueue<T> {
|
|
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) {
|
|
front = rear = r;
|
|
} else {
|
|
rear.next = r;
|
|
rear = r;
|
|
}
|
|
}
|
|
}
|