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

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.74 by dl, Tue Feb 22 00:39:31 2011 UTC vs.
Revision 1.79 by jsr166, Fri Jun 10 18:10:53 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   package jsr166y;
8  
9   import java.io.Serializable;
10   import java.util.Collection;
11 import java.util.Collections;
11   import java.util.List;
12   import java.util.RandomAccess;
14 import java.util.Map;
13   import java.lang.ref.WeakReference;
14   import java.lang.ref.ReferenceQueue;
15   import java.util.concurrent.Callable;
16   import java.util.concurrent.CancellationException;
17   import java.util.concurrent.ExecutionException;
20 import java.util.concurrent.Executor;
21 import java.util.concurrent.ExecutorService;
18   import java.util.concurrent.Future;
19   import java.util.concurrent.RejectedExecutionException;
20   import java.util.concurrent.RunnableFuture;
# Line 282 | Line 278 | public abstract class ForkJoinTask<V> im
278                      if (s == 0)
279                          UNSAFE.compareAndSwapInt(this, statusOffset,
280                                                   0, SIGNAL);
281 <                    else
281 >                    else {
282                          wait(millis);
283 +                        if (millis > 0L)
284 +                            break;
285 +                    }
286                  }
287              }
288          }
# Line 381 | Line 380 | public abstract class ForkJoinTask<V> im
380       * periods. However, since we do not know when the last joiner
381       * completes, we must use weak references and expunge them. We do
382       * so on each operation (hence full locking). Also, some thread in
383 <     * any ForkJoinPool will call helpExpunge when its pool becomes
384 <     * isQuiescent.
383 >     * any ForkJoinPool will call helpExpungeStaleExceptions when its
384 >     * pool becomes isQuiescent.
385       */
386      static final class ExceptionNode extends WeakReference<ForkJoinTask<?>>{
387          final Throwable ex;
388          ExceptionNode next;
389 <        final long thrower;
389 >        final long thrower;  // use id not ref to avoid weak cycles
390          ExceptionNode(ForkJoinTask<?> task, Throwable ex, ExceptionNode next) {
391              super(task, exceptionTableRefQueue);
392              this.ex = ex;
# Line 403 | Line 402 | public abstract class ForkJoinTask<V> im
402       */
403      private int setExceptionalCompletion(Throwable ex) {
404          int h = System.identityHashCode(this);
405 <        ReentrantLock lock = exceptionTableLock;
405 >        final ReentrantLock lock = exceptionTableLock;
406          lock.lock();
407          try {
408              expungeStaleExceptions();
# Line 428 | Line 427 | public abstract class ForkJoinTask<V> im
427       */
428      private void clearExceptionalCompletion() {
429          int h = System.identityHashCode(this);
430 <        ReentrantLock lock = exceptionTableLock;
430 >        final ReentrantLock lock = exceptionTableLock;
431          lock.lock();
432          try {
433              ExceptionNode[] t = exceptionTable;
# Line 473 | Line 472 | public abstract class ForkJoinTask<V> im
472              return null;
473          int h = System.identityHashCode(this);
474          ExceptionNode e;
475 <        ReentrantLock lock = exceptionTableLock;
475 >        final ReentrantLock lock = exceptionTableLock;
476          lock.lock();
477          try {
478              expungeStaleExceptions();
# Line 488 | Line 487 | public abstract class ForkJoinTask<V> im
487          if (e == null || (ex = e.ex) == null)
488              return null;
489          if (e.thrower != Thread.currentThread().getId()) {
490 <            Class ec = ex.getClass();
490 >            Class<? extends Throwable> ec = ex.getClass();
491              try {
492                  Constructor<?> noArgCtor = null;
493                  Constructor<?>[] cs = ec.getConstructors();// public ctors only
# Line 539 | Line 538 | public abstract class ForkJoinTask<V> im
538      }
539  
540      /**
541 <     * If lock is available, poll any stale refs and remove them.
541 >     * If lock is available, poll stale refs and remove them.
542       * Called from ForkJoinPool when pools become quiescent.
543       */
544      static final void helpExpungeStaleExceptions() {
545 <        ReentrantLock lock = exceptionTableLock;
545 >        final ReentrantLock lock = exceptionTableLock;
546          if (lock.tryLock()) {
547              try {
548                  expungeStaleExceptions();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines