equal
deleted
inserted
replaced
94 /* When active: NULL |
94 /* When active: NULL |
95 * pending: this |
95 * pending: this |
96 * Enqueued: next reference in queue (or this if last) |
96 * Enqueued: next reference in queue (or this if last) |
97 * Inactive: this |
97 * Inactive: this |
98 */ |
98 */ |
|
99 @SuppressWarnings("rawtypes") |
99 Reference next; |
100 Reference next; |
100 |
101 |
101 /* When active: next element in a discovered reference list maintained by GC (or this if last) |
102 /* When active: next element in a discovered reference list maintained by GC (or this if last) |
102 * pending: next element in the pending list (or null if last) |
103 * pending: next element in the pending list (or null if last) |
103 * otherwise: NULL |
104 * otherwise: NULL |
117 /* List of References waiting to be enqueued. The collector adds |
118 /* List of References waiting to be enqueued. The collector adds |
118 * References to this list, while the Reference-handler thread removes |
119 * References to this list, while the Reference-handler thread removes |
119 * them. This list is protected by the above lock object. The |
120 * them. This list is protected by the above lock object. The |
120 * list uses the discovered field to link its elements. |
121 * list uses the discovered field to link its elements. |
121 */ |
122 */ |
122 private static Reference pending = null; |
123 private static Reference<Object> pending = null; |
123 |
124 |
124 /* High-priority thread to enqueue pending References |
125 /* High-priority thread to enqueue pending References |
125 */ |
126 */ |
126 private static class ReferenceHandler extends Thread { |
127 private static class ReferenceHandler extends Thread { |
127 |
128 |
129 super(g, name); |
130 super(g, name); |
130 } |
131 } |
131 |
132 |
132 public void run() { |
133 public void run() { |
133 for (;;) { |
134 for (;;) { |
134 Reference r; |
135 Reference<Object> r; |
135 synchronized (lock) { |
136 synchronized (lock) { |
136 if (pending != null) { |
137 if (pending != null) { |
137 r = pending; |
138 r = pending; |
138 pending = r.discovered; |
139 pending = r.discovered; |
139 r.discovered = null; |
140 r.discovered = null; |
164 if (r instanceof Cleaner) { |
165 if (r instanceof Cleaner) { |
165 ((Cleaner)r).clean(); |
166 ((Cleaner)r).clean(); |
166 continue; |
167 continue; |
167 } |
168 } |
168 |
169 |
169 ReferenceQueue q = r.queue; |
170 ReferenceQueue<Object> q = r.queue; |
170 if (q != ReferenceQueue.NULL) q.enqueue(r); |
171 if (q != ReferenceQueue.NULL) q.enqueue(r); |
171 } |
172 } |
172 } |
173 } |
173 } |
174 } |
174 |
175 |