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

Comparing jsr166/src/main/java/util/concurrent/SynchronousQueue.java (file contents):
Revision 1.84 by jsr166, Mon Dec 12 20:53:11 2011 UTC vs.
Revision 1.85 by jsr166, Mon Dec 19 19:58:00 2011 UTC

# Line 401 | Line 401 | public class SynchronousQueue<E> extends
401               * and don't wait at all, so are trapped in transfer
402               * method rather than calling awaitFulfill.
403               */
404 <            long lastTime = timed ? System.nanoTime() : 0;
404 >            final long deadline = timed ? System.nanoTime() + nanos : 0L;
405              Thread w = Thread.currentThread();
406              int spins = (shouldSpin(s) ?
407                           (timed ? maxTimedSpins : maxUntimedSpins) : 0);
# Line 412 | Line 412 | public class SynchronousQueue<E> extends
412                  if (m != null)
413                      return m;
414                  if (timed) {
415 <                    long now = System.nanoTime();
416 <                    nanos -= now - lastTime;
417 <                    lastTime = now;
418 <                    if (nanos <= 0) {
415 >                    nanos = deadline - System.nanoTime();
416 >                    if (nanos <= 0L) {
417                          s.tryCancel();
418                          continue;
419                      }
# Line 707 | Line 705 | public class SynchronousQueue<E> extends
705           */
706          Object awaitFulfill(QNode s, E e, boolean timed, long nanos) {
707              /* Same idea as TransferStack.awaitFulfill */
708 <            long lastTime = timed ? System.nanoTime() : 0;
708 >            final long deadline = timed ? System.nanoTime() + nanos : 0L;
709              Thread w = Thread.currentThread();
710              int spins = ((head.next == s) ?
711                           (timed ? maxTimedSpins : maxUntimedSpins) : 0);
# Line 718 | Line 716 | public class SynchronousQueue<E> extends
716                  if (x != e)
717                      return x;
718                  if (timed) {
719 <                    long now = System.nanoTime();
720 <                    nanos -= now - lastTime;
723 <                    lastTime = now;
724 <                    if (nanos <= 0) {
719 >                    nanos = deadline - System.nanoTime();
720 >                    if (nanos <= 0L) {
721                          s.tryCancel(e);
722                          continue;
723                      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines