687 |
|
return (n >= 0) ? 0 : -n; // ignore transient negative |
688 |
|
} |
689 |
|
|
690 |
< |
/** |
690 |
> |
/** |
691 |
|
* Provides a more accurate estimate of whether this queue has |
692 |
|
* any tasks than does queueSize, by checking whether a |
693 |
|
* near-empty queue has at least one unclaimed task. |
725 |
|
} |
726 |
|
} |
727 |
|
|
728 |
< |
/** |
728 |
> |
/** |
729 |
|
* Initializes or doubles the capacity of array. Call either |
730 |
|
* by owner or with lock held -- it is OK for base, but not |
731 |
|
* top, to move while resizings are in progress. |
907 |
|
* or any other cancelled task. Returns (true) on any CAS |
908 |
|
* or consistency check failure so caller can retry. |
909 |
|
* |
910 |
< |
* @return false if no progress can be made, else true; |
910 |
> |
* @return false if no progress can be made, else true |
911 |
|
*/ |
912 |
|
final boolean tryRemoveAndExec(ForkJoinTask<?> task) { |
913 |
|
boolean stat = true, removed = false, empty = true; |
1131 |
|
*/ |
1132 |
|
private static final int SEED_INCREMENT = 0x61c88647; |
1133 |
|
|
1134 |
< |
/** |
1134 |
> |
/* |
1135 |
|
* Bits and masks for control variables |
1136 |
|
* |
1137 |
|
* Field ctl is a long packed with: |
1521 |
|
(m = ws.length - 1) < 0) { // initialize workQueues |
1522 |
|
int p = config & SMASK; // find power of two table size |
1523 |
|
int n = (p > 1) ? p - 1 : 1; // ensure at least 2 slots |
1524 |
< |
n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; |
1525 |
< |
n |= n >>> 8; n |= n >>> 16; n = (n + 1) << 1; |
1524 |
> |
n |= n >>> 1; |
1525 |
> |
n |= n >>> 2; |
1526 |
> |
n |= n >>> 4; |
1527 |
> |
n |= n >>> 8; |
1528 |
> |
n |= n >>> 16; |
1529 |
> |
n = (n + 1) << 1; |
1530 |
|
WorkQueue[] nws = ((ws = workQueues) == null || ws.length == 0 ? |
1531 |
|
new WorkQueue[n] : null); |
1532 |
|
if (((ps = plock) & PL_LOCK) != 0 || |
2131 |
|
w.runSubtask(t); |
2132 |
|
} |
2133 |
|
} |
2134 |
< |
else if (active) { // decrement active count without queuing |
2134 |
> |
else if (active) { // decrement active count without queuing |
2135 |
|
long nc = (c = ctl) - AC_UNIT; |
2136 |
|
if ((int)(nc >> AC_SHIFT) + (config & SMASK) == 0) |
2137 |
< |
return; // bypass decrement-then-increment |
2137 |
> |
return; // bypass decrement-then-increment |
2138 |
|
if (U.compareAndSwapLong(this, CTL, c, nc)) |
2139 |
|
active = false; |
2140 |
|
} |
2189 |
|
* producing extra tasks amortizes the uncertainty of progress and |
2190 |
|
* diffusion assumptions. |
2191 |
|
* |
2192 |
< |
* So, users will want to use values larger, but not much larger |
2192 |
> |
* So, users will want to use values larger (but not much larger) |
2193 |
|
* than 1 to both smooth over transient shortages and hedge |
2194 |
|
* against uneven progress; as traded off against the cost of |
2195 |
|
* extra task overhead. We leave the user to pick a threshold |