ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166y/ForkJoinPool.java
(Generate patch)

Comparing jsr166/src/jsr166y/ForkJoinPool.java (file contents):
Revision 1.50 by dl, Fri Dec 4 12:09:46 2009 UTC vs.
Revision 1.51 by dl, Fri Dec 4 15:46:38 2009 UTC

# Line 1493 | Line 1493 | public class ForkJoinPool extends Abstra
1493              long prev = w.lastEventCount;
1494              WaitQueueNode node = null;
1495              WaitQueueNode h;
1496 <            boolean helpSignal = false;
1497 <            while (eventCount == prev &&
1496 >            long ec;
1497 >            while ((ec = eventCount) == prev &&
1498                     ((h = syncStack) == null || h.count == prev)) {
1499                  if (node == null)
1500                      node = new WaitQueueNode(prev, w);
1501                  if (casBarrierStack(node.next = h, node)) {
1502 <                    if (!Thread.interrupted() && node.thread != null &&
1503 <                        eventCount == prev) {
1504 <                        if (h == null && // cover signalWork race
1505 <                            ForkJoinWorkerThread.hasQueuedTasks(workers))
1506 <                            helpSignal = true;
1507 <                        else
1508 <                            LockSupport.park(this);
1509 <                    }
1510 <                    if (node.thread != null)
1502 >                    if (!Thread.interrupted() &&
1503 >                        node.thread != null &&
1504 >                        eventCount == prev &&
1505 >                        (h != null || // cover signalWork race
1506 >                         (!ForkJoinWorkerThread.hasQueuedTasks(workers) &&
1507 >                          eventCount == prev)))
1508 >                        LockSupport.park(this);
1509 >                    ec = eventCount;
1510 >                    if (node.thread != null) {
1511                          node.thread = null;
1512 +                        if (ec == prev)
1513 +                            casEventCount(prev, prev + 1); // help signal
1514 +                    }
1515                      break;
1516                  }
1517              }
1518 <            long ec = eventCount;
1516 <            if (ec != prev)
1517 <                w.lastEventCount = ec;
1518 <            else if (helpSignal)
1519 <                casEventCount(ec, ec + 1);
1518 >            w.lastEventCount = ec;
1519              ensureSync();
1520          }
1521      }
1522  
1524
1523      /**
1524       * Returns {@code true} if a new sync event occurred since last
1525       * call to sync or this method, if so, updating caller's count.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines