7 |
|
package jsr166y; |
8 |
|
|
9 |
|
import java.util.concurrent.*; |
10 |
– |
|
10 |
|
import java.util.ArrayList; |
11 |
|
import java.util.Arrays; |
12 |
|
import java.util.Collection; |
345 |
|
* "while ((local = field) != 0)") which are usually the simplest |
346 |
|
* way to ensure the required read orderings (which are sometimes |
347 |
|
* critical). Also several occurrences of the unusual "do {} |
348 |
< |
* while(!cas...)" which is the simplest way to force an update of |
348 |
> |
* while (!cas...)" which is the simplest way to force an update of |
349 |
|
* a CAS'ed variable. There are also other coding oddities that |
350 |
|
* help some methods perform reasonably even when interpreted (not |
351 |
|
* compiled), at the expense of some messy constructions that |
831 |
|
UNSAFE.compareAndSwapInt(this, spareWaitersOffset, |
832 |
|
sw, w.nextSpare)) { |
833 |
|
int c; // increment running count before resume |
834 |
< |
do {} while(!UNSAFE.compareAndSwapInt |
835 |
< |
(this, workerCountsOffset, |
836 |
< |
c = workerCounts, c + ONE_RUNNING)); |
834 |
> |
do {} while (!UNSAFE.compareAndSwapInt |
835 |
> |
(this, workerCountsOffset, |
836 |
> |
c = workerCounts, c + ONE_RUNNING)); |
837 |
|
if (w.tryUnsuspend()) |
838 |
|
LockSupport.unpark(w); |
839 |
|
else // back out if w was shutdown |
1720 |
|
throws InterruptedException { |
1721 |
|
try { |
1722 |
|
return termination.awaitAdvanceInterruptibly(0, timeout, unit) > 0; |
1723 |
< |
} catch(TimeoutException ex) { |
1723 |
> |
} catch (TimeoutException ex) { |
1724 |
|
return false; |
1725 |
|
} |
1726 |
|
} |