55 |
|
* @throws NullPointerException if the specified element is <tt>null</tt>. |
56 |
|
*/ |
57 |
|
public boolean offer(E o) { |
58 |
+ |
final ReentrantLock lock = this.lock; |
59 |
|
lock.lock(); |
60 |
|
try { |
61 |
|
E first = q.peek(); |
105 |
|
} |
106 |
|
|
107 |
|
public E take() throws InterruptedException { |
108 |
+ |
final ReentrantLock lock = this.lock; |
109 |
|
lock.lockInterruptibly(); |
110 |
|
try { |
111 |
|
for (;;) { |
132 |
|
} |
133 |
|
|
134 |
|
public E poll(long time, TimeUnit unit) throws InterruptedException { |
135 |
+ |
final ReentrantLock lock = this.lock; |
136 |
|
lock.lockInterruptibly(); |
137 |
|
long nanos = unit.toNanos(time); |
138 |
|
try { |
166 |
|
|
167 |
|
|
168 |
|
public E poll() { |
169 |
+ |
final ReentrantLock lock = this.lock; |
170 |
|
lock.lock(); |
171 |
|
try { |
172 |
|
E first = q.peek(); |
185 |
|
} |
186 |
|
|
187 |
|
public E peek() { |
188 |
+ |
final ReentrantLock lock = this.lock; |
189 |
|
lock.lock(); |
190 |
|
try { |
191 |
|
return q.peek(); |
195 |
|
} |
196 |
|
|
197 |
|
public int size() { |
198 |
+ |
final ReentrantLock lock = this.lock; |
199 |
|
lock.lock(); |
200 |
|
try { |
201 |
|
return q.size(); |
209 |
|
throw new NullPointerException(); |
210 |
|
if (c == this) |
211 |
|
throw new IllegalArgumentException(); |
212 |
+ |
final ReentrantLock lock = this.lock; |
213 |
|
lock.lock(); |
214 |
|
try { |
215 |
|
int n = 0; |
235 |
|
throw new IllegalArgumentException(); |
236 |
|
if (maxElements <= 0) |
237 |
|
return 0; |
238 |
+ |
final ReentrantLock lock = this.lock; |
239 |
|
lock.lock(); |
240 |
|
try { |
241 |
|
int n = 0; |
259 |
|
* The queue will be empty after this call returns. |
260 |
|
*/ |
261 |
|
public void clear() { |
262 |
+ |
final ReentrantLock lock = this.lock; |
263 |
|
lock.lock(); |
264 |
|
try { |
265 |
|
q.clear(); |
278 |
|
} |
279 |
|
|
280 |
|
public Object[] toArray() { |
281 |
+ |
final ReentrantLock lock = this.lock; |
282 |
|
lock.lock(); |
283 |
|
try { |
284 |
|
return q.toArray(); |
288 |
|
} |
289 |
|
|
290 |
|
public <T> T[] toArray(T[] array) { |
291 |
+ |
final ReentrantLock lock = this.lock; |
292 |
|
lock.lock(); |
293 |
|
try { |
294 |
|
return q.toArray(array); |
298 |
|
} |
299 |
|
|
300 |
|
public boolean remove(Object o) { |
301 |
+ |
final ReentrantLock lock = this.lock; |
302 |
|
lock.lock(); |
303 |
|
try { |
304 |
|
return q.remove(o); |
317 |
|
* @return an iterator over the elements in this queue. |
318 |
|
*/ |
319 |
|
public Iterator<E> iterator() { |
320 |
+ |
final ReentrantLock lock = this.lock; |
321 |
|
lock.lock(); |
322 |
|
try { |
323 |
|
return new Itr(q.iterator()); |
337 |
|
} |
338 |
|
|
339 |
|
public E next() { |
340 |
+ |
final ReentrantLock lock = DelayQueue.this.lock; |
341 |
|
lock.lock(); |
342 |
|
try { |
343 |
|
return iter.next(); |
347 |
|
} |
348 |
|
|
349 |
|
public void remove() { |
350 |
+ |
final ReentrantLock lock = DelayQueue.this.lock; |
351 |
|
lock.lock(); |
352 |
|
try { |
353 |
|
iter.remove(); |