373 |
|
// Exception table support |
374 |
|
|
375 |
|
/** |
376 |
< |
* Table of exceptions thrown by tasks, to enable reporting by |
377 |
< |
* callers. Because exceptions are rare, we don't directly keep |
376 |
> |
* Hash table of exceptions thrown by tasks, to enable reporting |
377 |
> |
* by callers. Because exceptions are rare, we don't directly keep |
378 |
|
* them with task objects, but instead use a weak ref table. Note |
379 |
|
* that cancellation exceptions don't appear in the table, but are |
380 |
|
* instead recorded as status values. |
381 |
|
* |
382 |
< |
* Note: These statics are initialized below in static block. |
382 |
> |
* The exception table has a fixed capacity. |
383 |
|
*/ |
384 |
< |
private static final ExceptionNode[] exceptionTable; |
385 |
< |
private static final ReentrantLock exceptionTableLock; |
386 |
< |
private static final ReferenceQueue<ForkJoinTask<?>> exceptionTableRefQueue; |
384 |
> |
private static final ExceptionNode[] exceptionTable |
385 |
> |
= new ExceptionNode[32]; |
386 |
|
|
387 |
< |
/** |
388 |
< |
* Fixed capacity for exceptionTable. |
389 |
< |
*/ |
390 |
< |
private static final int EXCEPTION_MAP_CAPACITY = 32; |
387 |
> |
/** Lock protecting access to exceptionTable. */ |
388 |
> |
private static final ReentrantLock exceptionTableLock |
389 |
> |
= new ReentrantLock(); |
390 |
> |
|
391 |
> |
/** Reference queue of stale exceptionally completed tasks. */ |
392 |
> |
private static final ReferenceQueue<ForkJoinTask<?>> exceptionTableRefQueue |
393 |
> |
= new ReferenceQueue<ForkJoinTask<?>>(); |
394 |
|
|
395 |
|
/** |
396 |
|
* Key-value nodes for exception table. The chained hash table |
1487 |
|
// VarHandle mechanics |
1488 |
|
private static final VarHandle STATUS; |
1489 |
|
static { |
1488 |
– |
exceptionTableLock = new ReentrantLock(); |
1489 |
– |
exceptionTableRefQueue = new ReferenceQueue<ForkJoinTask<?>>(); |
1490 |
– |
exceptionTable = new ExceptionNode[EXCEPTION_MAP_CAPACITY]; |
1490 |
|
try { |
1491 |
|
MethodHandles.Lookup l = MethodHandles.lookup(); |
1492 |
|
STATUS = l.findVarHandle(ForkJoinTask.class, "status", int.class); |