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.71 by jsr166, Mon Sep 6 21:36:43 2010 UTC vs.
Revision 1.76 by jsr166, Tue Sep 7 07:24:39 2010 UTC

# Line 300 | Line 300 | public class ForkJoinPool extends Abstra
300       * about the same time as another is needlessly being created. We
301       * counteract this and related slop in part by requiring resumed
302       * spares to immediately recheck (in preStep) to see whether they
303 <     * they should re-suspend.
303 >     * should re-suspend.
304       *
305       * 6. Killing off unneeded workers. A timeout mechanism is used to
306       * shed unused workers: The oldest (first) event queue waiter uses
# Line 429 | Line 429 | public class ForkJoinPool extends Abstra
429  
430      /**
431       * The wakeup interval (in nanoseconds) for the oldest worker
432 <     * worker waiting for an event invokes tryShutdownUnusedWorker to shrink
432 >     * waiting for an event invokes tryShutdownUnusedWorker to shrink
433       * the number of workers.  The exact value does not matter too
434       * much, but should be long enough to slowly release resources
435       * during long periods without use without disrupting normal use.
# Line 806 | Line 806 | public class ForkJoinPool extends Abstra
806      // Maintaining parallelism
807  
808      /**
809 <     * Pushes worker onto the spare stack
809 >     * Pushes worker onto the spare stack.
810       */
811      final void pushSpare(ForkJoinWorkerThread w) {
812          int ns = (++w.spareCount << SPARE_COUNT_SHIFT) | (w.poolIndex + 1);
# Line 1125 | Line 1125 | public class ForkJoinPool extends Abstra
1125      }
1126  
1127      /**
1128 <     * Clear out and cancel submissions, ignoring exceptions
1128 >     * Clears out and cancels submissions, ignoring exceptions.
1129       */
1130      private void cancelSubmissions() {
1131          ForkJoinTask<?> task;
# Line 1140 | Line 1140 | public class ForkJoinPool extends Abstra
1140      // misc support for ForkJoinWorkerThread
1141  
1142      /**
1143 <     * Returns pool number
1143 >     * Returns pool number.
1144       */
1145      final int getPoolNumber() {
1146          return poolNumber;
1147      }
1148  
1149      /**
1150 <     * Tries to accumulates steal count from a worker, clearing
1151 <     * the worker's value.
1150 >     * Tries to accumulate steal count from a worker, clearing
1151 >     * the worker's value if successful.
1152       *
1153       * @return true if worker steal count now zero
1154       */
# Line 1172 | Line 1172 | public class ForkJoinPool extends Abstra
1172          int pc = parallelism; // use parallelism, not rc
1173          int ac = runState;    // no mask -- artificially boosts during shutdown
1174          // Use exact results for small values, saturate past 4
1175 <        return pc <= ac? 0 : pc >>> 1 <= ac? 1 : pc >>> 2 <= ac? 3 : pc >>> 3;
1175 >        return ((pc <= ac) ? 0 :
1176 >                (pc >>> 1 <= ac) ? 1 :
1177 >                (pc >>> 2 <= ac) ? 3 :
1178 >                pc >>> 3);
1179      }
1180  
1181      // Public and protected methods
# Line 1222 | Line 1225 | public class ForkJoinPool extends Abstra
1225       * use {@link #defaultForkJoinWorkerThreadFactory}.
1226       * @param handler the handler for internal worker threads that
1227       * terminate due to unrecoverable errors encountered while executing
1228 <     * tasks. For default value, use <code>null</code>.
1228 >     * tasks. For default value, use {@code null}.
1229       * @param asyncMode if true,
1230       * establishes local first-in-first-out scheduling mode for forked
1231       * tasks that are never joined. This mode may be more appropriate
1232       * than default locally stack-based mode in applications in which
1233       * worker threads only process event-style asynchronous tasks.
1234 <     * For default value, use <code>false</code>.
1234 >     * For default value, use {@code false}.
1235       * @throws IllegalArgumentException if parallelism less than or
1236       *         equal to zero, or greater than implementation limit
1237       * @throws NullPointerException if the factory is null
# Line 1438 | Line 1441 | public class ForkJoinPool extends Abstra
1441  
1442      /**
1443       * Returns the number of worker threads that have started but not
1444 <     * yet terminated.  This result returned by this method may differ
1444 >     * yet terminated.  The result returned by this method may differ
1445       * from {@link #getParallelism} when threads are created to
1446       * maintain parallelism when others are cooperatively blocked.
1447       *
# Line 1839 | Line 1842 | public class ForkJoinPool extends Abstra
1842      private static final long eventCountOffset =
1843          objectFieldOffset("eventCount", ForkJoinPool.class);
1844      private static final long eventWaitersOffset =
1845 <        objectFieldOffset("eventWaiters",ForkJoinPool.class);
1845 >        objectFieldOffset("eventWaiters", ForkJoinPool.class);
1846      private static final long stealCountOffset =
1847 <        objectFieldOffset("stealCount",ForkJoinPool.class);
1847 >        objectFieldOffset("stealCount", ForkJoinPool.class);
1848      private static final long spareWaitersOffset =
1849 <        objectFieldOffset("spareWaiters",ForkJoinPool.class);
1849 >        objectFieldOffset("spareWaiters", ForkJoinPool.class);
1850  
1851      private static long objectFieldOffset(String field, Class<?> klazz) {
1852          try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines