ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CountedCompleter.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CountedCompleter.java (file contents):
Revision 1.45 by jsr166, Sat Jul 27 19:53:27 2013 UTC vs.
Revision 1.46 by jsr166, Mon Dec 9 17:00:23 2013 UTC

# Line 139 | Line 139 | package java.util.concurrent;
139   * {@code tryComplete}) the pending count is set to one:
140   *
141   * <pre> {@code
142 < * class ForEach<E> ...
142 > * class ForEach<E> ... {
143 > *   ...
144   *   public void compute() { // version 2
145   *     if (hi - lo >= 2) {
146   *       int mid = (lo + hi) >>> 1;
# Line 153 | Line 154 | package java.util.concurrent;
154   *       tryComplete();
155   *     }
156   *   }
157 < * }</pre>
157 > * }}</pre>
158   *
159   * As a further improvement, notice that the left task need not even exist.
160   * Instead of creating a new one, we can iterate using the original task,
# Line 162 | Line 163 | package java.util.concurrent;
163   * {@code tryComplete()} can be replaced with {@link #propagateCompletion}.
164   *
165   * <pre> {@code
166 < * class ForEach<E> ...
166 > * class ForEach<E> ... {
167 > *   ...
168   *   public void compute() { // version 3
169 < *     int l = lo,  h = hi;
169 > *     int l = lo, h = hi;
170   *     while (h - l >= 2) {
171   *       int mid = (l + h) >>> 1;
172   *       addToPendingCount(1);
# Line 175 | Line 177 | package java.util.concurrent;
177   *       op.apply(array[l]);
178   *     propagateCompletion();
179   *   }
180 < * }</pre>
180 > * }}</pre>
181   *
182   * Additional improvements of such classes might entail precomputing
183   * pending counts so that they can be established in constructors,
# Line 373 | Line 375 | package java.util.concurrent;
375   * // sample use:
376   * PacketSender p = new PacketSender();
377   * new HeaderBuilder(p, ...).fork();
378 < * new BodyBuilder(p, ...).fork();
377 < * }</pre>
378 > * new BodyBuilder(p, ...).fork();}</pre>
379   *
380   * @since 1.8
381   * @author Doug Lea

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines