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.72 by jsr166, Tue Sep 7 06:19:05 2010 UTC vs.
Revision 1.78 by dl, Tue Sep 7 14:52:24 2010 UTC

# Line 6 | Line 6
6  
7   package jsr166y;
8  
9 import java.util.concurrent.*;
9   import java.util.ArrayList;
10   import java.util.Arrays;
11   import java.util.Collection;
12   import java.util.Collections;
13   import java.util.List;
14 + import java.util.concurrent.AbstractExecutorService;
15 + import java.util.concurrent.Callable;
16 + import java.util.concurrent.CountDownLatch;
17 + import java.util.concurrent.ExecutorService;
18 + 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;
23 + import java.util.concurrent.atomic.AtomicInteger;
24   import java.util.concurrent.locks.LockSupport;
25   import java.util.concurrent.locks.ReentrantLock;
17 import java.util.concurrent.atomic.AtomicInteger;
18 import java.util.concurrent.CountDownLatch;
26  
27   /**
28   * An {@link ExecutorService} for running {@link ForkJoinTask}s.
# Line 429 | Line 436 | public class ForkJoinPool extends Abstra
436  
437      /**
438       * The wakeup interval (in nanoseconds) for the oldest worker
439 <     * waiting for an event invokes tryShutdownUnusedWorker to shrink
440 <     * the number of workers.  The exact value does not matter too
441 <     * much, but should be long enough to slowly release resources
442 <     * during long periods without use without disrupting normal use.
439 >     * waiting for an event to invoke tryShutdownUnusedWorker to
440 >     * shrink the number of workers.  The exact value does not matter
441 >     * too much. It must be short enough to release resources during
442 >     * sustained periods of idleness, but not so short that threads
443 >     * are continually re-created.
444       */
445      private static final long SHRINK_RATE_NANOS =
446          30L * 1000L * 1000L * 1000L; // 2 per minute
# Line 604 | Line 612 | public class ForkJoinPool extends Abstra
612       * (rarely) necessary when other count updates lag.
613       *
614       * @param dr -- either zero or ONE_RUNNING
615 <     * @param dt == either zero or ONE_TOTAL
615 >     * @param dt -- either zero or ONE_TOTAL
616       */
617      private void decrementWorkerCounts(int dr, int dt) {
618          for (;;) {
# Line 806 | Line 814 | public class ForkJoinPool extends Abstra
814      // Maintaining parallelism
815  
816      /**
817 <     * Pushes worker onto the spare stack
817 >     * Pushes worker onto the spare stack.
818       */
819      final void pushSpare(ForkJoinWorkerThread w) {
820          int ns = (++w.spareCount << SPARE_COUNT_SHIFT) | (w.poolIndex + 1);
# Line 1225 | Line 1233 | public class ForkJoinPool extends Abstra
1233       * use {@link #defaultForkJoinWorkerThreadFactory}.
1234       * @param handler the handler for internal worker threads that
1235       * terminate due to unrecoverable errors encountered while executing
1236 <     * tasks. For default value, use <code>null</code>.
1236 >     * tasks. For default value, use {@code null}.
1237       * @param asyncMode if true,
1238       * establishes local first-in-first-out scheduling mode for forked
1239       * tasks that are never joined. This mode may be more appropriate
1240       * than default locally stack-based mode in applications in which
1241       * worker threads only process event-style asynchronous tasks.
1242 <     * For default value, use <code>false</code>.
1242 >     * For default value, use {@code false}.
1243       * @throws IllegalArgumentException if parallelism less than or
1244       *         equal to zero, or greater than implementation limit
1245       * @throws NullPointerException if the factory is null
# Line 1441 | Line 1449 | public class ForkJoinPool extends Abstra
1449  
1450      /**
1451       * Returns the number of worker threads that have started but not
1452 <     * yet terminated.  This result returned by this method may differ
1452 >     * yet terminated.  The result returned by this method may differ
1453       * from {@link #getParallelism} when threads are created to
1454       * maintain parallelism when others are cooperatively blocked.
1455       *
# Line 1842 | Line 1850 | public class ForkJoinPool extends Abstra
1850      private static final long eventCountOffset =
1851          objectFieldOffset("eventCount", ForkJoinPool.class);
1852      private static final long eventWaitersOffset =
1853 <        objectFieldOffset("eventWaiters",ForkJoinPool.class);
1853 >        objectFieldOffset("eventWaiters", ForkJoinPool.class);
1854      private static final long stealCountOffset =
1855 <        objectFieldOffset("stealCount",ForkJoinPool.class);
1855 >        objectFieldOffset("stealCount", ForkJoinPool.class);
1856      private static final long spareWaitersOffset =
1857 <        objectFieldOffset("spareWaiters",ForkJoinPool.class);
1857 >        objectFieldOffset("spareWaiters", ForkJoinPool.class);
1858  
1859      private static long objectFieldOffset(String field, Class<?> klazz) {
1860          try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines