56 |
|
* maximum number of running threads to 32767. Attempts to create |
57 |
|
* pools with greater than the maximum result in |
58 |
|
* IllegalArgumentExceptions. |
59 |
+ |
* |
60 |
+ |
* @since 1.7 |
61 |
+ |
* @author Doug Lea |
62 |
|
*/ |
63 |
|
public class ForkJoinPool extends AbstractExecutorService { |
64 |
|
|
1821 |
|
|
1822 |
|
private static long fieldOffset(String fieldName) |
1823 |
|
throws NoSuchFieldException { |
1824 |
< |
return _unsafe.objectFieldOffset |
1824 |
> |
return UNSAFE.objectFieldOffset |
1825 |
|
(ForkJoinPool.class.getDeclaredField(fieldName)); |
1826 |
|
} |
1827 |
|
|
1828 |
< |
static final Unsafe _unsafe; |
1828 |
> |
static final Unsafe UNSAFE; |
1829 |
|
static final long eventCountOffset; |
1830 |
|
static final long workerCountsOffset; |
1831 |
|
static final long runControlOffset; |
1834 |
|
|
1835 |
|
static { |
1836 |
|
try { |
1837 |
< |
_unsafe = getUnsafe(); |
1837 |
> |
UNSAFE = getUnsafe(); |
1838 |
|
eventCountOffset = fieldOffset("eventCount"); |
1839 |
|
workerCountsOffset = fieldOffset("workerCounts"); |
1840 |
|
runControlOffset = fieldOffset("runControl"); |
1846 |
|
} |
1847 |
|
|
1848 |
|
private boolean casEventCount(long cmp, long val) { |
1849 |
< |
return _unsafe.compareAndSwapLong(this, eventCountOffset, cmp, val); |
1849 |
> |
return UNSAFE.compareAndSwapLong(this, eventCountOffset, cmp, val); |
1850 |
|
} |
1851 |
|
private boolean casWorkerCounts(int cmp, int val) { |
1852 |
< |
return _unsafe.compareAndSwapInt(this, workerCountsOffset, cmp, val); |
1852 |
> |
return UNSAFE.compareAndSwapInt(this, workerCountsOffset, cmp, val); |
1853 |
|
} |
1854 |
|
private boolean casRunControl(int cmp, int val) { |
1855 |
< |
return _unsafe.compareAndSwapInt(this, runControlOffset, cmp, val); |
1855 |
> |
return UNSAFE.compareAndSwapInt(this, runControlOffset, cmp, val); |
1856 |
|
} |
1857 |
|
private boolean casSpareStack(WaitQueueNode cmp, WaitQueueNode val) { |
1858 |
< |
return _unsafe.compareAndSwapObject(this, spareStackOffset, cmp, val); |
1858 |
> |
return UNSAFE.compareAndSwapObject(this, spareStackOffset, cmp, val); |
1859 |
|
} |
1860 |
|
private boolean casBarrierStack(WaitQueueNode cmp, WaitQueueNode val) { |
1861 |
< |
return _unsafe.compareAndSwapObject(this, syncStackOffset, cmp, val); |
1861 |
> |
return UNSAFE.compareAndSwapObject(this, syncStackOffset, cmp, val); |
1862 |
|
} |
1863 |
|
} |