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.104 by jsr166, Wed Jun 8 05:12:25 2011 UTC vs.
Revision 1.105 by jsr166, Fri Jun 10 18:10:53 2011 UTC

# Line 19 | Line 19 | import java.util.concurrent.Future;
19   import java.util.concurrent.RejectedExecutionException;
20   import java.util.concurrent.RunnableFuture;
21   import java.util.concurrent.TimeUnit;
22 import java.util.concurrent.TimeoutException;
22   import java.util.concurrent.atomic.AtomicInteger;
23   import java.util.concurrent.locks.LockSupport;
24   import java.util.concurrent.locks.ReentrantLock;
# Line 102 | Line 101 | import java.util.concurrent.locks.Condit
101   * daemon} mode, there is typically no need to explicitly {@link
102   * #shutdown} such a pool upon program exit.
103   *
104 < * <pre>
104 > *  <pre> {@code
105   * static final ForkJoinPool mainPool = new ForkJoinPool();
106   * ...
107   * public void sort(long[] array) {
108   *   mainPool.invoke(new SortTask(array, 0, array.length));
109 < * }
111 < * </pre>
109 > * }}</pre>
110   *
111   * <p><b>Implementation notes</b>: This implementation restricts the
112   * maximum number of running threads to 32767. Attempts to create
# Line 949 | Line 947 | public class ForkJoinPool extends Abstra
947              int pc = parallelism;
948              do {
949                  ForkJoinWorkerThread[] ws; ForkJoinWorkerThread w;
950 <                int e, ac, tc, rc, i;
950 >                int e, ac, tc, i;
951                  long c = ctl;
952                  int u = (int)(c >>> 32);
953                  if ((e = (int)c) < 0) {
# Line 989 | Line 987 | public class ForkJoinPool extends Abstra
987      }
988  
989      /**
990 <     * Decrements blockedCount and increments active count
990 >     * Decrements blockedCount and increments active count.
991       */
992      private void postBlock() {
993          long c;
# Line 1007 | Line 1005 | public class ForkJoinPool extends Abstra
1005       * @param joinMe the task
1006       */
1007      final void tryAwaitJoin(ForkJoinTask<?> joinMe) {
1010        int s;
1008          Thread.interrupted(); // clear interrupts before checking termination
1009          if (joinMe.status >= 0) {
1010              if (tryPreBlock()) {
# Line 1021 | Line 1018 | public class ForkJoinPool extends Abstra
1018  
1019      /**
1020       * Possibly blocks the given worker waiting for joinMe to
1021 <     * complete or timeout
1021 >     * complete or timeout.
1022       *
1023       * @param joinMe the task
1024       * @param millis the wait time for underlying Object.wait
# Line 1057 | Line 1054 | public class ForkJoinPool extends Abstra
1054      }
1055  
1056      /**
1057 <     * If necessary, compensates for blocker, and blocks
1057 >     * If necessary, compensates for blocker, and blocks.
1058       */
1059      private void awaitBlocker(ManagedBlocker blocker)
1060          throws InterruptedException {
# Line 2118 | Line 2115 | public class ForkJoinPool extends Abstra
2115          modifyThreadPermission = new RuntimePermission("modifyThread");
2116          defaultForkJoinWorkerThreadFactory =
2117              new DefaultForkJoinWorkerThreadFactory();
2121        int s;
2118          try {
2119              UNSAFE = getUnsafe();
2120              Class<?> k = ForkJoinPool.class;
# Line 2134 | Line 2130 | public class ForkJoinPool extends Abstra
2130                  (k.getDeclaredField("scanGuard"));
2131              nextWorkerNumberOffset = UNSAFE.objectFieldOffset
2132                  (k.getDeclaredField("nextWorkerNumber"));
2137            Class<?> a = ForkJoinTask[].class;
2138            ABASE = UNSAFE.arrayBaseOffset(a);
2139            s = UNSAFE.arrayIndexScale(a);
2133          } catch (Exception e) {
2134              throw new Error(e);
2135          }
2136 +        Class<?> a = ForkJoinTask[].class;
2137 +        ABASE = UNSAFE.arrayBaseOffset(a);
2138 +        int s = UNSAFE.arrayIndexScale(a);
2139          if ((s & (s-1)) != 0)
2140              throw new Error("data type scale not a power of two");
2141          ASHIFT = 31 - Integer.numberOfLeadingZeros(s);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines