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.52 by jsr166, Fri Dec 2 15:47:22 2011 UTC vs.
Revision 1.53 by jsr166, Mon Dec 19 19:58:00 2011 UTC

# Line 491 | Line 491 | public class Exchanger<V> {
491       */
492      private Object awaitNanos(Node node, Slot slot, long nanos) {
493          int spins = TIMED_SPINS;
494 <        long lastTime = 0;
494 >        long deadline = 0L;
495          Thread w = null;
496          for (;;) {
497              Object v = node.get();
498              if (v != null)
499                  return v;
500              long now = System.nanoTime();
501 <            if (w == null)
501 >            if (w == null) {
502 >                deadline = now + nanos;
503                  w = Thread.currentThread();
504 +            }
505              else
506 <                nanos -= now - lastTime;
507 <            lastTime = now;
506 <            if (nanos > 0) {
506 >                nanos = deadline - now;
507 >            if (nanos > 0L) {
508                  if (spins > 0)
509                      --spins;
510                  else if (node.waiter == null)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines