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

Comparing jsr166/src/main/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.254 by jsr166, Mon Aug 3 17:53:33 2015 UTC vs.
Revision 1.255 by dl, Wed Aug 5 13:31:36 2015 UTC

# Line 759 | Line 759 | public class ForkJoinPool extends Abstra
759          static final int MAXIMUM_QUEUE_CAPACITY = 1 << 26; // 64M
760  
761          // Instance fields
762 +
763          volatile int scanState;    // versioned, negative if inactive
764          int stackPred;             // pool stack (ctl) predecessor
765          int nsteals;               // number of steals
# Line 772 | Line 773 | public class ForkJoinPool extends Abstra
773          final ForkJoinWorkerThread owner; // owning thread or null if shared
774          volatile Thread parker;    // == owner during call to park; else null
775          volatile ForkJoinTask<?> currentJoin;  // task being joined in awaitJoin
776 <        volatile ForkJoinTask<?> currentSteal; // mainly used by helpStealer
776 >        @sun.misc.Contended("group2") // separate from other fields
777 >        volatile ForkJoinTask<?> currentSteal; // nonnull when running some task
778  
779          WorkQueue(ForkJoinPool pool, ForkJoinWorkerThread owner) {
780              this.pool = pool;
# Line 1033 | Line 1035 | public class ForkJoinPool extends Abstra
1035                          U.getAndSetObject(a, offset, null);
1036                      if (t != null) {
1037                          base = b;
1038 <                        (currentSteal = t).doExec();
1038 >                        t.doExec();
1039                          if (++nexec > POLL_LIMIT)
1040                              break;
1041                      }
# Line 1647 | Line 1649 | public class ForkJoinPool extends Abstra
1649          long c; int sp, wl, m; WorkQueue v;
1650          if ((sp = (int)(c = ctl)) != 0 && w != null &&
1651              ws != null && (wl = ws.length) > 0 &&
1652 <            ((m = wl - 1) & ((sp ^ r) >>> 16)) == 0 &&
1652 >            ((m = wl - 1) & ((sp ^ r) >>> 16)) <= 1 &&
1653              (v = ws[m & sp]) != null) {
1654              long nc = (v.stackPred & SP_MASK) | (UC_MASK & (c + AC_UNIT));
1655              int ns = sp & ~UNSIGNALLED;
# Line 1864 | Line 1866 | public class ForkJoinPool extends Abstra
1866                      if (t == null || b++ != q.base)
1867                          break;                     // busy or empty
1868                      else if (ss < 0) {
1869 <                        tryReactivate(w, ws, r);
1870 <                        break;                     // retry upon rescan
1869 >                        if ((ss = w.scanState) >= 0) {
1870 >                            tryReactivate(w, ws, r);
1871 >                            break;                 // retry upon rescan
1872 >                        }
1873 >                        r |= (1 << 31);            // ensure full scan
1874                      }
1875                      else if (!U.compareAndSwapObject(a, offset, t, null))
1876                          break;                     // contended

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines