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

Comparing jsr166/src/main/java/util/concurrent/DelayQueue.java (file contents):
Revision 1.20 by dl, Sun Oct 19 13:38:34 2003 UTC vs.
Revision 1.21 by dl, Tue Dec 23 19:38:09 2003 UTC

# Line 55 | Line 55 | public class DelayQueue<E extends Delaye
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();
# Line 104 | Line 105 | public class DelayQueue<E extends Delaye
105      }
106  
107      public E take() throws InterruptedException {
108 +        final ReentrantLock lock = this.lock;
109          lock.lockInterruptibly();
110          try {
111              for (;;) {
# Line 130 | Line 132 | public class DelayQueue<E extends Delaye
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 {
# Line 163 | Line 166 | public class DelayQueue<E extends Delaye
166  
167  
168      public E poll() {
169 +        final ReentrantLock lock = this.lock;
170          lock.lock();
171          try {
172              E first = q.peek();
# Line 181 | Line 185 | public class DelayQueue<E extends Delaye
185      }
186  
187      public E peek() {
188 +        final ReentrantLock lock = this.lock;
189          lock.lock();
190          try {
191              return q.peek();
# Line 190 | Line 195 | public class DelayQueue<E extends Delaye
195      }
196  
197      public int size() {
198 +        final ReentrantLock lock = this.lock;
199          lock.lock();
200          try {
201              return q.size();
# Line 203 | Line 209 | public class DelayQueue<E extends Delaye
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;
# Line 228 | Line 235 | public class DelayQueue<E extends Delaye
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;
# Line 251 | Line 259 | public class DelayQueue<E extends Delaye
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();
# Line 269 | Line 278 | public class DelayQueue<E extends Delaye
278      }
279  
280      public Object[] toArray() {
281 +        final ReentrantLock lock = this.lock;
282          lock.lock();
283          try {
284              return q.toArray();
# Line 278 | Line 288 | public class DelayQueue<E extends Delaye
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);
# Line 287 | Line 298 | public class DelayQueue<E extends Delaye
298      }
299  
300      public boolean remove(Object o) {
301 +        final ReentrantLock lock = this.lock;
302          lock.lock();
303          try {
304              return q.remove(o);
# Line 305 | Line 317 | public class DelayQueue<E extends Delaye
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());
# Line 324 | Line 337 | public class DelayQueue<E extends Delaye
337          }
338  
339          public E next() {
340 +            final ReentrantLock lock = DelayQueue.this.lock;
341              lock.lock();
342              try {
343                  return iter.next();
# Line 333 | Line 347 | public class DelayQueue<E extends Delaye
347          }
348  
349          public void remove() {
350 +            final ReentrantLock lock = DelayQueue.this.lock;
351              lock.lock();
352              try {
353                  iter.remove();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines