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} |
469 |
|
} |
470 |
|
|
471 |
|
/** |
472 |
< |
* Removes exception node and clears status |
472 |
> |
* Removes exception node and clears status. |
473 |
|
*/ |
474 |
|
private void clearExceptionalCompletion() { |
475 |
|
int h = System.identityHashCode(this); |
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 |
|
|
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 |
|
/** |
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 |
|
|
1078 |
|
wt.pool.helpQuiescePool(wt.workQueue); |
1079 |
|
} |
1080 |
|
else |
1081 |
< |
ForkJoinPool.externalHelpQuiescePool(); |
1081 |
> |
ForkJoinPool.quiesceCommonPool(); |
1082 |
|
} |
1083 |
|
|
1084 |
|
/** |
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 |
|
} |