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

Comparing jsr166/src/main/java/util/concurrent/Exchanger.java (file contents):
Revision 1.17 by jsr166, Mon May 2 03:41:20 2005 UTC vs.
Revision 1.18 by dl, Sun May 8 21:50:03 2005 UTC

# Line 254 | Line 254 | public class Exchanger<V> {
254           */
255          Object waitForHole(boolean timed, long nanos) {
256              long lastTime = (timed)? System.nanoTime() : 0;
257 <            Object h = get();
258 <            while (h == null) {
259 <                if (!timed)
257 >            Object h;
258 >            while ((h = get()) == null) {
259 >                // If interrupted or timed out, try to cancel by
260 >                // CASing FAIL as hole value.
261 >                if (Thread.currentThread().isInterrupted() ||
262 >                    (timed && nanos <= 0))
263 >                    compareAndSet(null, FAIL);
264 >                else if (!timed)
265                      LockSupport.park();
266                  else {
267                      LockSupport.parkNanos(nanos);
# Line 264 | Line 269 | public class Exchanger<V> {
269                      nanos -= now - lastTime;
270                      lastTime = now;
271                  }
267                // If interrupted or timed out, try to cancel by
268                // CASing FAIL as hole value.
269                if ((h = get()) == null &&
270                    (Thread.currentThread().isInterrupted() ||
271                     (timed && nanos <= 0))) {
272                    compareAndSet(null, FAIL);
273                    h = get();
274                }
272              }
273              return h;
274          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines