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

Comparing jsr166/src/jsr166y/ForkJoinWorkerThread.java (file contents):
Revision 1.36 by dl, Fri Jul 23 13:07:43 2010 UTC vs.
Revision 1.37 by dl, Fri Jul 23 14:09:17 2010 UTC

# Line 198 | Line 198 | public class ForkJoinWorkerThread extend
198       * Initialized in onStart, to improve memory locality.
199       */
200      private ForkJoinTask<?>[] queue;
201 <    
201 >
202      /**
203       * Index (mod queue.length) of least valid queue slot, which is
204       * always the next position to steal from if nonempty.
# Line 269 | Line 269 | public class ForkJoinWorkerThread extend
269       * pool-wide.
270       */
271      private final boolean locallyFifo;
272 <    
272 >
273      /**
274       * Index of this worker in pool array. Set once by pool before
275       * running, and accessed directly by pool to locate this worker in
# Line 295 | Line 295 | public class ForkJoinWorkerThread extend
295       * others.
296       */
297      private volatile ForkJoinTask<?> currentJoin;
298 <    
298 >
299      /**
300       * The task most recently stolen from another worker (or
301       * submission queue).  Not volatile because always read/written in
# Line 431 | Line 431 | public class ForkJoinWorkerThread extend
431                  currentSteal = null;
432                  emptyScans = 0;
433              }
434 <            else
434 >            else
435                  ++emptyScans;
436          }
437      }
# Line 570 | Line 570 | public class ForkJoinWorkerThread extend
570  
571      /**
572       * Returns a popped task, or null if empty. Assumes active status.
573 <     * Called only by current thread.
573 >     * Called only by current thread.
574       */
575      final ForkJoinTask<?> popTask() {
576          int s;
# Line 963 | Line 963 | public class ForkJoinWorkerThread extend
963              ForkJoinTask<?> t;
964              int i = (q.length - 1) & --s;
965              long u = (i << qShift) + qBase; // raw offset
966 <            if ((t = q[i]) != null &&
966 >            if ((t = q[i]) != null &&
967                  UNSAFE.compareAndSwapObject(q, u, t, null)) {
968                  /*
969                   * This recheck (and similarly in helpJoinTask)
# Line 1025 | Line 1025 | public class ForkJoinWorkerThread extend
1025                  ForkJoinTask<?>[] q;
1026                  while ((b = v.base) != v.sp && (q = v.queue) != null) {
1027                      int i = (q.length - 1) & b;
1028 <                    long u = (i << qShift) + qBase;
1028 >                    long u = (i << qShift) + qBase;
1029                      ForkJoinTask<?> t = q[i];
1030                      if (task.status < 0)          // stale
1031                          continue restart;
# Line 1033 | Line 1033 | public class ForkJoinWorkerThread extend
1033                          if (t == null)            // producer stalled
1034                              continue restart;     // retry via restart
1035                          if (UNSAFE.compareAndSwapObject(q, u, t, null)) {
1036 <                            if (joinMe.status < 0) {
1036 >                            if (joinMe.status < 0) {
1037                                  UNSAFE.putObjectVolatile(q, u, t);
1038                                  return;           // back out on cancel
1039                              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines