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

Comparing jsr166/src/jsr166e/ForkJoinTask.java (file contents):
Revision 1.8 by jsr166, Sun Dec 30 02:05:53 2012 UTC vs.
Revision 1.11 by jsr166, Sun Jan 20 03:44:14 2013 UTC

# Line 134 | Line 134 | import java.lang.reflect.Constructor;
134   * (DAG). Otherwise, executions may encounter a form of deadlock as
135   * tasks cyclically wait for each other.  However, this framework
136   * supports other methods and techniques (for example the use of
137 < * {@link Phaser}, {@link #helpQuiesce}, and {@link #complete}) that
137 > * {@link java.util.concurrent.Phaser}, {@link #helpQuiesce}, and
138 > * {@link #complete}) that
139   * may be of use in constructing custom subclasses for problems that
140   * are not statically structured as DAGs. To support such usages a
141   * ForkJoinTask may be atomically <em>tagged</em> with a {@code short}
# Line 606 | Line 607 | public abstract class ForkJoinTask<V> im
607                  throw (Error)ex;
608              if (ex instanceof RuntimeException)
609                  throw (RuntimeException)ex;
610 <            throw uncheckedThrowable(ex, RuntimeException.class);
610 >            ForkJoinTask.<RuntimeException>uncheckedThrow(ex);
611          }
612      }
613  
# Line 616 | Line 617 | public abstract class ForkJoinTask<V> im
617       * unchecked exceptions
618       */
619      @SuppressWarnings("unchecked") static <T extends Throwable>
620 <        T uncheckedThrowable(final Throwable t, final Class<T> c) {
621 <        return (T)t; // rely on vacuous cast
620 >        void uncheckedThrow(Throwable t) throws T {
621 >        if (t != null)
622 >            throw (T)t; // rely on vacuous cast
623      }
624  
625      /**
# Line 652 | Line 654 | public abstract class ForkJoinTask<V> im
654          if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
655              ((ForkJoinWorkerThread)t).workQueue.push(this);
656          else
657 <            ForkJoinPool.commonPool.externalPush(this);
657 >            ForkJoinPool.common.externalPush(this);
658          return this;
659      }
660  
# Line 1076 | Line 1078 | public abstract class ForkJoinTask<V> im
1078              wt.pool.helpQuiescePool(wt.workQueue);
1079          }
1080          else
1081 <            ForkJoinPool.externalHelpQuiescePool();
1081 >            ForkJoinPool.quiesceCommonPool();
1082      }
1083  
1084      /**
# Line 1484 | Line 1486 | public abstract class ForkJoinTask<V> im
1486      private static sun.misc.Unsafe getUnsafe() {
1487          try {
1488              return sun.misc.Unsafe.getUnsafe();
1489 <        } catch (SecurityException se) {
1490 <            try {
1491 <                return java.security.AccessController.doPrivileged
1492 <                    (new java.security
1493 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
1494 <                        public sun.misc.Unsafe run() throws Exception {
1495 <                            java.lang.reflect.Field f = sun.misc
1496 <                                .Unsafe.class.getDeclaredField("theUnsafe");
1497 <                            f.setAccessible(true);
1498 <                            return (sun.misc.Unsafe) f.get(null);
1499 <                        }});
1500 <            } catch (java.security.PrivilegedActionException e) {
1501 <                throw new RuntimeException("Could not initialize intrinsics",
1502 <                                           e.getCause());
1503 <            }
1489 >        } catch (SecurityException tryReflectionInstead) {}
1490 >        try {
1491 >            return java.security.AccessController.doPrivileged
1492 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
1493 >                public sun.misc.Unsafe run() throws Exception {
1494 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
1495 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
1496 >                        f.setAccessible(true);
1497 >                        Object x = f.get(null);
1498 >                        if (k.isInstance(x))
1499 >                            return k.cast(x);
1500 >                    }
1501 >                    throw new NoSuchFieldError("the Unsafe");
1502 >                }});
1503 >        } catch (java.security.PrivilegedActionException e) {
1504 >            throw new RuntimeException("Could not initialize intrinsics",
1505 >                                       e.getCause());
1506          }
1507      }
1504
1508   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines