6 |
|
|
7 |
|
package jsr166y; |
8 |
|
|
9 |
– |
import java.util.concurrent.*; |
9 |
|
import java.util.ArrayList; |
10 |
|
import java.util.Arrays; |
11 |
|
import java.util.Collection; |
12 |
|
import java.util.Collections; |
13 |
|
import java.util.List; |
14 |
+ |
import java.util.concurrent.AbstractExecutorService; |
15 |
+ |
import java.util.concurrent.Callable; |
16 |
+ |
import java.util.concurrent.CountDownLatch; |
17 |
+ |
import java.util.concurrent.ExecutorService; |
18 |
+ |
import java.util.concurrent.Future; |
19 |
+ |
import java.util.concurrent.RejectedExecutionException; |
20 |
+ |
import java.util.concurrent.RunnableFuture; |
21 |
+ |
import java.util.concurrent.TimeUnit; |
22 |
+ |
import java.util.concurrent.TimeoutException; |
23 |
+ |
import java.util.concurrent.atomic.AtomicInteger; |
24 |
|
import java.util.concurrent.locks.LockSupport; |
25 |
|
import java.util.concurrent.locks.ReentrantLock; |
17 |
– |
import java.util.concurrent.atomic.AtomicInteger; |
18 |
– |
import java.util.concurrent.CountDownLatch; |
26 |
|
|
27 |
|
/** |
28 |
|
* An {@link ExecutorService} for running {@link ForkJoinTask}s. |
436 |
|
|
437 |
|
/** |
438 |
|
* The wakeup interval (in nanoseconds) for the oldest worker |
439 |
< |
* waiting for an event invokes tryShutdownUnusedWorker to shrink |
440 |
< |
* the number of workers. The exact value does not matter too |
441 |
< |
* much, but should be long enough to slowly release resources |
442 |
< |
* during long periods without use without disrupting normal use. |
439 |
> |
* waiting for an event to invoke tryShutdownUnusedWorker to |
440 |
> |
* shrink the number of workers. The exact value does not matter |
441 |
> |
* too much. It must be short enough to release resources during |
442 |
> |
* sustained periods of idleness, but not so short that threads |
443 |
> |
* are continually re-created. |
444 |
|
*/ |
445 |
|
private static final long SHRINK_RATE_NANOS = |
446 |
|
30L * 1000L * 1000L * 1000L; // 2 per minute |
612 |
|
* (rarely) necessary when other count updates lag. |
613 |
|
* |
614 |
|
* @param dr -- either zero or ONE_RUNNING |
615 |
< |
* @param dt == either zero or ONE_TOTAL |
615 |
> |
* @param dt -- either zero or ONE_TOTAL |
616 |
|
*/ |
617 |
|
private void decrementWorkerCounts(int dr, int dt) { |
618 |
|
for (;;) { |