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

Comparing jsr166/src/jsr166y/CountedCompleter.java (file contents):
Revision 1.5 by jsr166, Sun Oct 21 05:28:08 2012 UTC vs.
Revision 1.13 by jsr166, Sun Nov 18 18:03:10 2012 UTC

# Line 77 | Line 77 | package jsr166y;
77   * continuations, other threads need not block waiting to perform
78   * them.
79   *
80 < * <p> For example, here is an initial version of a class that uses
80 > * <p>For example, here is an initial version of a class that uses
81   * divide-by-two recursive decomposition to divide work into single
82   * pieces (leaf tasks). Even when work is split into individual calls,
83   * tree-based techniques are usually preferable to directly forking
# Line 142 | Line 142 | package jsr166y;
142   *
143   * As a further improvement, notice that the left task need not even
144   * exist.  Instead of creating a new one, we can iterate using the
145 < * original task, and add a pending count for each fork:
145 > * original task, and add a pending count for each fork.
146   *
147   * <pre> {@code
148   * class ForEach<E> ...
# Line 378 | Line 378 | public abstract class CountedCompleter<T
378      }
379  
380      /**
381 +     * Returns the root of the current computation; i.e., this
382 +     * task if it has no completer, else its completer's root.
383 +     *
384 +     * @return the root of the current computation
385 +     */
386 +    public final CountedCompleter<?> getRoot() {
387 +        CountedCompleter<?> a = this, p;
388 +        while ((p = a.completer) != null)
389 +            a = p;
390 +        return a;
391 +    }
392 +
393 +    /**
394       * If the pending count is nonzero, decrements the count;
395       * otherwise invokes {@link #onCompletion} and then similarly
396       * tries to complete this task's completer, if one exists,
# Line 465 | Line 478 | public abstract class CountedCompleter<T
478          }
479      }
480  
468
481      /**
482       * Returns a sun.misc.Unsafe.  Suitable for use in a 3rd party package.
483       * Replace with a simple call to Unsafe.getUnsafe when integrating
# Line 493 | Line 505 | public abstract class CountedCompleter<T
505              }
506          }
507      }
496
508   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines