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.68 by jsr166, Wed Sep 1 06:40:12 2010 UTC vs.
Revision 1.71 by jsr166, Mon Sep 6 21:36:43 2010 UTC

# Line 7 | Line 7
7   package jsr166y;
8  
9   import java.util.concurrent.*;
10
10   import java.util.ArrayList;
11   import java.util.Arrays;
12   import java.util.Collection;
# Line 346 | Line 345 | public class ForkJoinPool extends Abstra
345       * "while ((local = field) != 0)") which are usually the simplest
346       * way to ensure the required read orderings (which are sometimes
347       * critical). Also several occurrences of the unusual "do {}
348 <     * while(!cas...)" which is the simplest way to force an update of
348 >     * while (!cas...)" which is the simplest way to force an update of
349       * a CAS'ed variable. There are also other coding oddities that
350       * help some methods perform reasonably even when interpreted (not
351       * compiled), at the expense of some messy constructions that
# Line 674 | Line 673 | public class ForkJoinPool extends Abstra
673      }
674  
675      /**
676 <     * Nulls out record of worker in workers array
676 >     * Nulls out record of worker in workers array.
677       */
678      private void forgetWorker(ForkJoinWorkerThread w) {
679          int idx = w.poolIndex;
# Line 832 | Line 831 | public class ForkJoinPool extends Abstra
831              UNSAFE.compareAndSwapInt(this, spareWaitersOffset,
832                                       sw, w.nextSpare)) {
833              int c; // increment running count before resume
834 <            do {} while(!UNSAFE.compareAndSwapInt
835 <                        (this, workerCountsOffset,
836 <                         c = workerCounts, c + ONE_RUNNING));
834 >            do {} while (!UNSAFE.compareAndSwapInt
835 >                         (this, workerCountsOffset,
836 >                          c = workerCounts, c + ONE_RUNNING));
837              if (w.tryUnsuspend())
838                  LockSupport.unpark(w);
839              else   // back out if w was shutdown
# Line 1107 | Line 1106 | public class ForkJoinPool extends Abstra
1106                                       c = eventCount, c+1);
1107              eventWaiters = 0L; // clobber lists
1108              spareWaiters = 0;
1109 <            ForkJoinWorkerThread[] ws = workers;
1111 <            int n = ws.length;
1112 <            for (int i = 0; i < n; ++i) {
1113 <                ForkJoinWorkerThread w = ws[i];
1109 >            for (ForkJoinWorkerThread w : workers) {
1110                  if (w != null) {
1111                      w.shutdown();
1112                      if (passes > 0 && !w.isTerminated()) {
# Line 1527 | Line 1523 | public class ForkJoinPool extends Abstra
1523       */
1524      public long getQueuedTaskCount() {
1525          long count = 0;
1526 <        ForkJoinWorkerThread[] ws = workers;
1531 <        int n = ws.length;
1532 <        for (int i = 0; i < n; ++i) {
1533 <            ForkJoinWorkerThread w = ws[i];
1526 >        for (ForkJoinWorkerThread w : workers)
1527              if (w != null)
1528                  count += w.getQueueSize();
1536        }
1529          return count;
1530      }
1531  
# Line 1588 | Line 1580 | public class ForkJoinPool extends Abstra
1580       */
1581      protected int drainTasksTo(Collection<? super ForkJoinTask<?>> c) {
1582          int count = submissionQueue.drainTo(c);
1583 <        ForkJoinWorkerThread[] ws = workers;
1592 <        int n = ws.length;
1593 <        for (int i = 0; i < n; ++i) {
1594 <            ForkJoinWorkerThread w = ws[i];
1583 >        for (ForkJoinWorkerThread w : workers)
1584              if (w != null)
1585                  count += w.drainTasksTo(c);
1597        }
1586          return count;
1587      }
1588  
# Line 1721 | Line 1709 | public class ForkJoinPool extends Abstra
1709          throws InterruptedException {
1710          try {
1711              return termination.awaitAdvanceInterruptibly(0, timeout, unit) > 0;
1712 <        } catch(TimeoutException ex) {
1712 >        } catch (TimeoutException ex) {
1713              return false;
1714          }
1715      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines