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.95 by dl, Fri Mar 4 13:29:39 2011 UTC vs.
Revision 1.99 by dl, Wed Mar 23 11:27:43 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   package jsr166y;
# Line 714 | Line 714 | public class ForkJoinPool extends Abstra
714       */
715      private boolean scan(ForkJoinWorkerThread w, int a) {
716          int g = scanGuard; // mask 0 avoids useless scans if only one active
717 <        int m = parallelism == 1 - a? 0 : g & SMASK;
717 >        int m = (parallelism == 1 - a && blockedCount == 0) ? 0 : g & SMASK;
718          ForkJoinWorkerThread[] ws = workers;
719          if (ws == null || ws.length <= m)         // staleness check
720              return false;
# Line 864 | Line 864 | public class ForkJoinPool extends Abstra
864                  w.parked = false;
865                  if (w.eventCount != v)
866                      break;
867 <                else if (System.nanoTime() - startTime < SHRINK_RATE)
867 >                else if (System.nanoTime() - startTime <
868 >                         SHRINK_RATE - (SHRINK_RATE / 10)) // timing slop
869                      Thread.interrupted();          // spurious wakeup
870                  else if (UNSAFE.compareAndSwapLong(this, ctlOffset,
871                                                     currentCtl, prevCtl)) {
# Line 1146 | Line 1147 | public class ForkJoinPool extends Abstra
1147                          ws[k] = w;
1148                          nextWorkerIndex = k + 1;
1149                          int m = g & SMASK;
1150 <                        g = k >= m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1);
1150 >                        g = k > m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1);
1151                      }
1152                  } finally {
1153                      scanGuard = g;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines