421 |
|
static final int ASYNC = 1; |
422 |
|
static final int NESTED = -1; |
423 |
|
|
424 |
+ |
/** |
425 |
+ |
* Spins before blocking in waitingGet |
426 |
+ |
*/ |
427 |
+ |
static final int SPINS = (Runtime.getRuntime().availableProcessors() > 1 ? |
428 |
+ |
1 << 8 : 0); |
429 |
+ |
|
430 |
|
/* ------------- Base Completion classes and operations -------------- */ |
431 |
|
|
432 |
|
@SuppressWarnings("serial") |
1730 |
|
private Object waitingGet(boolean interruptible) { |
1731 |
|
Signaller q = null; |
1732 |
|
boolean queued = false; |
1733 |
< |
int spins = -1; |
1733 |
> |
int spins = SPINS; |
1734 |
|
Object r; |
1735 |
|
while ((r = result) == null) { |
1736 |
< |
if (spins < 0) |
1731 |
< |
spins = (Runtime.getRuntime().availableProcessors() > 1) ? |
1732 |
< |
1 << 8 : 0; // Use brief spin-wait on multiprocessors |
1733 |
< |
else if (spins > 0) { |
1736 |
> |
if (spins > 0) { |
1737 |
|
if (ThreadLocalRandom.nextSecondarySeed() >= 0) |
1738 |
|
--spins; |
1739 |
|
} |
1744 |
|
else { |
1745 |
|
try { |
1746 |
|
ForkJoinPool.managedBlock(q); |
1747 |
< |
} catch (InterruptedException ie) { |
1747 |
> |
} catch (InterruptedException ie) { // currently cannot happen |
1748 |
|
q.interrupted = true; |
1749 |
|
} |
1750 |
|
if (q.interrupted && interruptible) |