Methods Summary |
---|
boolean | enqueue(java.lang.ref.Reference r)
/* Called only by Reference class */
synchronized (r) {
if (r.queue == ENQUEUED) return false;
synchronized (lock) {
r.queue = ENQUEUED;
r.next = (head == null) ? r : head;
head = r;
queueLength++;
if (r instanceof FinalReference) {
sun.misc.VM.addFinalRefCount(1);
}
lock.notifyAll();
return true;
}
}
|
public java.lang.ref.Reference | poll()Polls this queue to see if a reference object is available. If one is
available without further delay then it is removed from the queue and
returned. Otherwise this method immediately returns null.
synchronized (lock) {
return reallyPoll();
}
|
private java.lang.ref.Reference | reallyPoll() /* Must hold lock */
if (head != null) {
Reference<? extends T> r = head;
head = (r.next == r) ? null : r.next;
r.queue = NULL;
r.next = r;
queueLength--;
if (r instanceof FinalReference) {
sun.misc.VM.addFinalRefCount(-1);
}
return r;
}
return null;
|
public java.lang.ref.Reference | remove(long timeout)Removes the next reference object in this queue, blocking until either
one becomes available or the given timeout period expires.
This method does not offer real-time guarantees: It schedules the
timeout as if by invoking the {@link Object#wait(long)} method.
if (timeout < 0) {
throw new IllegalArgumentException("Negative timeout value");
}
synchronized (lock) {
Reference<? extends T> r = reallyPoll();
if (r != null) return r;
for (;;) {
lock.wait(timeout);
r = reallyPoll();
if (r != null) return r;
if (timeout != 0) return null;
}
}
|
public java.lang.ref.Reference | remove()Removes the next reference object in this queue, blocking until one
becomes available.
return remove(0);
|