18 |
|
import java.util.concurrent.Future; |
19 |
|
import java.util.concurrent.RejectedExecutionException; |
20 |
|
import java.util.concurrent.RunnableFuture; |
21 |
– |
import java.util.concurrent.ThreadLocalRandom; |
21 |
|
import java.util.concurrent.TimeUnit; |
22 |
|
|
23 |
|
/** |
530 |
|
* Returns a new worker thread operating in the given pool. |
531 |
|
* |
532 |
|
* @param pool the pool this thread works in |
534 |
– |
* @throws NullPointerException if the pool is null |
533 |
|
* @return the new worker thread |
534 |
+ |
* @throws NullPointerException if the pool is null |
535 |
|
*/ |
536 |
|
public ForkJoinWorkerThread newThread(ForkJoinPool pool); |
537 |
|
} |
877 |
|
} |
878 |
|
} |
879 |
|
} |
880 |
< |
|
880 |
> |
|
881 |
|
/** |
882 |
|
* If present, removes from queue and executes the given task, |
883 |
|
* or any other cancelled task. Returns (true) on any CAS |
1385 |
|
if (wt != null && (w = wt.workQueue) != null) { |
1386 |
|
int ps; long sc; |
1387 |
|
w.qlock = -1; // ensure set |
1388 |
< |
do {} while(!U.compareAndSwapLong(this, STEALCOUNT, sc = stealCount, |
1389 |
< |
sc + w.nsteals)); |
1388 |
> |
do {} while (!U.compareAndSwapLong(this, STEALCOUNT, |
1389 |
> |
sc = stealCount, |
1390 |
> |
sc + w.nsteals)); |
1391 |
|
if (((ps = plock) & PL_LOCK) != 0 || |
1392 |
|
!U.compareAndSwapInt(this, PLOCK, ps, ps += PL_LOCK)) |
1393 |
|
ps = acquirePlock(); |
1533 |
|
(m = ws.length - 1) < 0) { // initialize workQueues |
1534 |
|
int p = parallelism; // find power of two table size |
1535 |
|
int n = (p > 1) ? p - 1 : 1; // ensure at least 2 slots |
1536 |
< |
n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; |
1537 |
< |
n |= n >>> 8; n |= n >>> 16; n = (n + 1) << 1; |
1536 |
> |
n |= n >>> 1; |
1537 |
> |
n |= n >>> 2; |
1538 |
> |
n |= n >>> 4; |
1539 |
> |
n |= n >>> 8; |
1540 |
> |
n |= n >>> 16; |
1541 |
> |
n = (n + 1) << 1; |
1542 |
|
WorkQueue[] nws = ((ws = workQueues) == null || ws.length == 0 ? |
1543 |
|
new WorkQueue[n] : null); |
1544 |
|
if (((ps = plock) & PL_LOCK) != 0 || |
1737 |
|
else if ((ns = w.nsteals) != 0) { // collect steals and retry |
1738 |
|
long sc; |
1739 |
|
w.nsteals = 0; |
1740 |
< |
do {} while(!U.compareAndSwapLong(this, STEALCOUNT, |
1741 |
< |
sc = stealCount, sc + ns)); |
1740 |
> |
do {} while (!U.compareAndSwapLong(this, STEALCOUNT, |
1741 |
> |
sc = stealCount, sc + ns)); |
1742 |
|
} |
1743 |
|
else { |
1744 |
|
long pc = ((d > 0 || ec != (e | INT_SIGN)) ? 0L : |
2100 |
|
w.currentSteal = ps; |
2101 |
|
} |
2102 |
|
} |
2103 |
< |
else if (active) { // decrement active count without queuing |
2103 |
> |
else if (active) { // decrement active count without queuing |
2104 |
|
long nc = ((c = ctl) & ~AC_MASK) | ((c & AC_MASK) - AC_UNIT); |
2105 |
|
if ((int)(nc >> AC_SHIFT) + parallelism == 0) |
2106 |
|
break; // bypass decrement-then-increment |
2499 |
|
* minimally only the latter. |
2500 |
|
* |
2501 |
|
* @param task the task |
2502 |
+ |
* @param <T> the type of the task's result |
2503 |
|
* @return the task's result |
2504 |
|
* @throws NullPointerException if the task is null |
2505 |
|
* @throws RejectedExecutionException if the task cannot be |
2548 |
|
* Submits a ForkJoinTask for execution. |
2549 |
|
* |
2550 |
|
* @param task the task to submit |
2551 |
+ |
* @param <T> the type of the task's result |
2552 |
|
* @return the task |
2553 |
|
* @throws NullPointerException if the task is null |
2554 |
|
* @throws RejectedExecutionException if the task cannot be |
3287 |
|
ForkJoinWorkerThreadFactory factory |
3288 |
|
= defaultForkJoinWorkerThreadFactory; |
3289 |
|
UncaughtExceptionHandler handler = null; |
3290 |
< |
try { // ignore exceptions in accesing/parsing properties |
3290 |
> |
try { // ignore exceptions in accessing/parsing properties |
3291 |
|
String pp = System.getProperty |
3292 |
|
("java.util.concurrent.ForkJoinPool.common.parallelism"); |
3293 |
|
String fp = System.getProperty |