/[classpath]/classpath/java/lang/ref/ReferenceQueue.java
ViewVC logotype

Diff of /classpath/java/lang/ref/ReferenceQueue.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.3.2.1 by tromey, Sat Aug 7 19:32:57 2004 UTC
# Line 1  Line 1 
1  /* java.lang.ref.ReferenceQueue  /* java.lang.ref.ReferenceQueue
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2004 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 50  package java.lang.ref; Line 50  package java.lang.ref;
50   * @author Jochen Hoenicke   * @author Jochen Hoenicke
51   * @see Reference#enqueue()   * @see Reference#enqueue()
52   */   */
53  public class ReferenceQueue  public class ReferenceQueue<T>
54  {  {
55    /**    /**
56     * This is a linked list of references.  If this is null, the list is     * This is a linked list of references.  If this is null, the list is
# Line 76  public class ReferenceQueue Line 76  public class ReferenceQueue
76     * @return a reference on the queue, if there is one,     * @return a reference on the queue, if there is one,
77     * <code>null</code> otherwise.       * <code>null</code> otherwise.  
78     */     */
79    public synchronized Reference poll()    public synchronized Reference<? extends T> poll()
80    {    {
81      return dequeue();      return dequeue();
82    }    }
# Line 85  public class ReferenceQueue Line 85  public class ReferenceQueue
85     * This is called by reference to enqueue itself on this queue.       * This is called by reference to enqueue itself on this queue.  
86     * @param ref the reference that should be enqueued.     * @param ref the reference that should be enqueued.
87     */     */
88    synchronized void enqueue(Reference ref)    synchronized void enqueue(Reference<? extends T> ref)
89    {    {
90      /* last reference will point to itself */      /* last reference will point to itself */
91      ref.nextOnQueue = first == null ? ref : first;      ref.nextOnQueue = first == null ? ref : first;
# Line 98  public class ReferenceQueue Line 98  public class ReferenceQueue
98     * Remove a reference from the queue, if there is one.     * Remove a reference from the queue, if there is one.
99     * @return the first element of the queue, or null if there isn't any.     * @return the first element of the queue, or null if there isn't any.
100     */     */
101    private Reference dequeue()    private Reference<? extends T> dequeue()
102    {    {
103      if (first == null)      if (first == null)
104        return null;        return null;
105    
106      Reference result = first;      Reference<? extends T> result = first;
107      first = (first == first.nextOnQueue) ? null : first.nextOnQueue;      first = (first == first.nextOnQueue) ? null : first.nextOnQueue;
108      result.nextOnQueue = null;      result.nextOnQueue = null;
109      return result;      return result;
# Line 118  public class ReferenceQueue Line 118  public class ReferenceQueue
118     * <code>null</code> if timeout period expired.       * <code>null</code> if timeout period expired.  
119     * @exception InterruptedException if the wait was interrupted.     * @exception InterruptedException if the wait was interrupted.
120     */     */
121    public synchronized Reference remove(long timeout)    public synchronized Reference<? extends T> remove(long timeout)
122      throws InterruptedException      throws InterruptedException
123    {    {
124      if (first == null)      if (first == null)
# Line 137  public class ReferenceQueue Line 137  public class ReferenceQueue
137     * @return the reference removed from the queue.       * @return the reference removed from the queue.  
138     * @exception InterruptedException if the wait was interrupted.     * @exception InterruptedException if the wait was interrupted.
139     */     */
140    public Reference remove()    public Reference<? extends T> remove()
141      throws InterruptedException      throws InterruptedException
142    {    {
143      return remove(0L);      return remove(0L);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26