Permalink
Browse files

upgrade to latest jsr166

  • Loading branch information...
kimchy committed Dec 14, 2013
1 parent 59d85bc commit 80ab75e54ef2116d20abded2c1464eb312a7f4a8
@@ -1392,6 +1392,7 @@ public CompletableFuture() {
*
* @param supplier a function returning the value to be used
* to complete the returned CompletableFuture
* @param <U> the function's return type
* @return the new CompletableFuture
*/
public static <U> CompletableFuture<U> supplyAsync(Generator<U> supplier) {
@@ -1410,6 +1411,7 @@ public CompletableFuture() {
* @param supplier a function returning the value to be used
* to complete the returned CompletableFuture
* @param executor the executor to use for asynchronous execution
* @param <U> the function's return type
* @return the new CompletableFuture
*/
public static <U> CompletableFuture<U> supplyAsync(Generator<U> supplier,
@@ -1462,6 +1464,7 @@ public CompletableFuture() {
* the given value.
*
* @param value the value
* @param <U> the type of the value
* @return the completed CompletableFuture
*/
public static <U> CompletableFuture<U> completedFuture(U value) {
@@ -2829,7 +2832,7 @@ else if (UNSAFE.compareAndSwapObject
}
if (dst == null)
dst = new CompletableFuture<U>();
if (e == null || ex != null)
if (ex != null)
dst.internalComplete(null, ex);
}
helpPostComplete();

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -686,7 +686,7 @@ protected final boolean exec() {
}
/**
* Returns the result of the computation. By default
* Returns the result of the computation. By default,
* returns {@code null}, which is appropriate for {@code Void}
* actions, but in other cases should be overridden, almost
* always to return a field or function of a field that
@@ -532,8 +532,8 @@ private static void checkPermission() {
* Returns a new worker thread operating in the given pool.
*
* @param pool the pool this thread works in
* @throws NullPointerException if the pool is null
* @return the new worker thread
* @throws NullPointerException if the pool is null
*/
public ForkJoinWorkerThread newThread(ForkJoinPool pool);
}
@@ -2098,7 +2098,7 @@ final void helpQuiescePool(WorkQueue w) {
w.currentSteal = ps;
}
}
else if (active) { // decrement active count without queuing
else if (active) { // decrement active count without queuing
long nc = ((c = ctl) & ~AC_MASK) | ((c & AC_MASK) - AC_UNIT);
if ((int)(nc >> AC_SHIFT) + parallelism == 0)
break; // bypass decrement-then-increment
@@ -2497,6 +2497,7 @@ public static ForkJoinPool commonPool() {
* minimally only the latter.
*
* @param task the task
* @param <T> the type of the task's result
* @return the task's result
* @throws NullPointerException if the task is null
* @throws RejectedExecutionException if the task cannot be
@@ -2545,6 +2546,7 @@ public void execute(Runnable task) {
* Submits a ForkJoinTask for execution.
*
* @param task the task to submit
* @param <T> the type of the task's result
* @return the task
* @throws NullPointerException if the task is null
* @throws RejectedExecutionException if the task cannot be
@@ -134,7 +134,7 @@
* (DAG). Otherwise, executions may encounter a form of deadlock as
* tasks cyclically wait for each other. However, this framework
* supports other methods and techniques (for example the use of
* {@link Phaser}, {@link #helpQuiesce}, and {@link #complete}) that
* {@link java.util.concurrent.Phaser Phaser}, {@link #helpQuiesce}, and {@link #complete}) that
* may be of use in constructing custom subclasses for problems that
* are not statically structured as DAGs. To support such usages, a
* ForkJoinTask may be atomically <em>tagged</em> with a {@code short}
@@ -411,11 +411,13 @@ private int doInvoke() {
final Throwable ex;
ExceptionNode next;
final long thrower; // use id not ref to avoid weak cycles
final int hashCode; // store task hashCode before weak ref disappears
ExceptionNode(ForkJoinTask<?> task, Throwable ex, ExceptionNode next) {
super(task, exceptionTableRefQueue);
this.ex = ex;
this.next = next;
this.thrower = Thread.currentThread().getId();
this.hashCode = System.identityHashCode(task);
}
}
@@ -571,15 +573,18 @@ else if (ps.length == 1 && ps[0] == Throwable.class)
return ex;
}
/**
* Poll stale refs and remove them. Call only while holding lock.
*/
/**
* Poll stale refs and remove them. Call only while holding lock.
*/
private static void expungeStaleExceptions() {
for (Object x; (x = exceptionTableRefQueue.poll()) != null;) {
if (x instanceof ExceptionNode) {
ForkJoinTask<?> key = ((ExceptionNode)x).get();
int hashCode = ((ExceptionNode)x).hashCode;
ExceptionNode[] t = exceptionTable;
int i = System.identityHashCode(key) & (t.length - 1);
int i = hashCode & (t.length - 1);
ExceptionNode e = t[i];
ExceptionNode pred = null;
while (e != null) {
@@ -782,6 +787,7 @@ else if (t.doJoin() < NORMAL)
* unprocessed.
*
* @param tasks the collection of tasks
* @param <T> the type of the values returned from the tasks
* @return the tasks argument, to simplify usage
* @throws NullPointerException if tasks or any element are null
*/
@@ -1444,6 +1450,7 @@ public final boolean exec() {
*
* @param runnable the runnable action
* @param result the result upon completion
* @param <T> the type of the result
* @return the task
*/
public static <T> ForkJoinTask<T> adapt(Runnable runnable, T result) {
@@ -1457,6 +1464,7 @@ public final boolean exec() {
* encountered into {@code RuntimeException}.
*
* @param callable the callable action
* @param <T> the type of the callable's result
* @return the task
*/
public static <T> ForkJoinTask<T> adapt(Callable<? extends T> callable) {
@@ -1470,6 +1478,8 @@ public final boolean exec() {
/**
* Saves this task to a stream (that is, serializes it).
*
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData the current run status and the exception thrown
* during execution, or {@code null} if none
*/
@@ -1481,6 +1491,10 @@ private void writeObject(java.io.ObjectOutputStream s)
/**
* Reconstitutes this task from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
@@ -15,7 +15,7 @@
* class Fibonacci extends RecursiveTask<Integer> {
* final int n;
* Fibonacci(int n) { this.n = n; }
* Integer compute() {
* protected Integer compute() {
* if (n <= 1)
* return n;
* Fibonacci f1 = new Fibonacci(n - 1);
@@ -46,6 +46,7 @@
/**
* The main computation performed by this task.
* @return the result of the computation
*/
protected abstract V compute();
Oops, something went wrong.

0 comments on commit 80ab75e

Please sign in to comment.