ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/PriorityBlockingQueue.java (file contents):
Revision 1.30 by dl, Wed Nov 12 01:04:24 2003 UTC vs.
Revision 1.31 by dl, Tue Dec 23 19:38:09 2003 UTC

# Line 143 | Line 143 | public class PriorityBlockingQueue<E> ex
143       */
144      public boolean offer(E o) {
145          if (o == null) throw new NullPointerException();
146 +        final ReentrantLock lock = this.lock;
147          lock.lock();
148          try {
149              boolean ok = q.offer(o);
# Line 184 | Line 185 | public class PriorityBlockingQueue<E> ex
185      }
186  
187      public E take() throws InterruptedException {
188 +        final ReentrantLock lock = this.lock;
189          lock.lockInterruptibly();
190          try {
191              try {
# Line 203 | Line 205 | public class PriorityBlockingQueue<E> ex
205  
206  
207      public E poll() {
208 +        final ReentrantLock lock = this.lock;
209          lock.lock();
210          try {
211              return q.poll();
# Line 213 | Line 216 | public class PriorityBlockingQueue<E> ex
216  
217      public E poll(long timeout, TimeUnit unit) throws InterruptedException {
218          long nanos = unit.toNanos(timeout);
219 +        final ReentrantLock lock = this.lock;
220          lock.lockInterruptibly();
221          try {
222              for (;;) {
# Line 234 | Line 238 | public class PriorityBlockingQueue<E> ex
238      }
239  
240      public E peek() {
241 +        final ReentrantLock lock = this.lock;
242          lock.lock();
243          try {
244              return q.peek();
# Line 243 | Line 248 | public class PriorityBlockingQueue<E> ex
248      }
249  
250      public int size() {
251 +        final ReentrantLock lock = this.lock;
252          lock.lock();
253          try {
254              return q.size();
# Line 261 | Line 267 | public class PriorityBlockingQueue<E> ex
267      }
268  
269      public boolean remove(Object o) {
270 +        final ReentrantLock lock = this.lock;
271          lock.lock();
272          try {
273              return q.remove(o);
# Line 270 | Line 277 | public class PriorityBlockingQueue<E> ex
277      }
278  
279      public boolean contains(Object o) {
280 +        final ReentrantLock lock = this.lock;
281          lock.lock();
282          try {
283              return q.contains(o);
# Line 279 | Line 287 | public class PriorityBlockingQueue<E> ex
287      }
288  
289      public Object[] toArray() {
290 +        final ReentrantLock lock = this.lock;
291          lock.lock();
292          try {
293              return q.toArray();
# Line 289 | Line 298 | public class PriorityBlockingQueue<E> ex
298  
299  
300      public String toString() {
301 +        final ReentrantLock lock = this.lock;
302          lock.lock();
303          try {
304              return q.toString();
# Line 302 | Line 312 | public class PriorityBlockingQueue<E> ex
312              throw new NullPointerException();
313          if (c == this)
314              throw new IllegalArgumentException();
315 +        final ReentrantLock lock = this.lock;
316          lock.lock();
317          try {
318              int n = 0;
# Line 323 | Line 334 | public class PriorityBlockingQueue<E> ex
334              throw new IllegalArgumentException();
335          if (maxElements <= 0)
336              return 0;
337 +        final ReentrantLock lock = this.lock;
338          lock.lock();
339          try {
340              int n = 0;
# Line 342 | Line 354 | public class PriorityBlockingQueue<E> ex
354       * The queue will be empty after this call returns.
355       */
356      public void clear() {
357 +        final ReentrantLock lock = this.lock;
358          lock.lock();
359          try {
360              q.clear();
# Line 351 | Line 364 | public class PriorityBlockingQueue<E> ex
364      }
365  
366      public <T> T[] toArray(T[] a) {
367 +        final ReentrantLock lock = this.lock;
368          lock.lock();
369          try {
370              return q.toArray(a);
# Line 370 | Line 384 | public class PriorityBlockingQueue<E> ex
384       * @return an iterator over the elements in this queue.
385       */
386      public Iterator<E> iterator() {
387 +        final ReentrantLock lock = this.lock;
388          lock.lock();
389          try {
390              return new Itr(q.iterator());
# Line 395 | Line 410 | public class PriorityBlockingQueue<E> ex
410          }
411  
412          public E next() {
413 +            ReentrantLock lock = PriorityBlockingQueue.this.lock;
414              lock.lock();
415              try {
416                  return iter.next();
# Line 404 | Line 420 | public class PriorityBlockingQueue<E> ex
420          }
421  
422          public void remove() {
423 +            ReentrantLock lock = PriorityBlockingQueue.this.lock;
424              lock.lock();
425              try {
426                  iter.remove();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines