| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | Striped64.Cell
Padded variant of AtomicLong supporting only raw accesses plus CAS. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv transient volatile long | base
Base value, used mainly when there is no contention, but also as a fallback during table initialization races. |
| private static final long | |
| pack-priv transient volatile int | busy
Spinlock (locked via CAS) used when resizing and/or creating Cells. |
| private static final long | |
| pack-priv transient volatile Striped64. | cells
Table of cells. |
| pack-priv static final int | NCPU
Number of CPUS, to place bound on table size |
| pack-priv static final Random | rng
Generator of new random hash codes |
| pack-priv static final ThreadLocal | threadHashCode
ThreadLocal holding a single-slot int array holding hash code. |
| private static final Unsafe |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final boolean | |
| pack-priv final boolean | |
| pack-priv abstract long | Returns: result of the update functionthe current value (of either base or a cell) currentValue, long the argument from a user update call newValue)Computes the function of current and new value. |
| private static Unsafe | |
| pack-priv final void | |
| pack-priv final void | retryUpdate(long
the value x, int[] the hash code holder hc, boolean false if CAS failed before call wasUncontended)Handles cases of updates involving initialization, resizing, creating new Cells, and/or contention. |
| base | back to summary |
|---|---|
| pack-priv transient volatile long base Base value, used mainly when there is no contention, but also as a fallback during table initialization races. Updated via CAS. | |
| baseOffset | back to summary |
|---|---|
| private static final long baseOffset | |
| busy | back to summary |
|---|---|
| pack-priv transient volatile int busy Spinlock (locked via CAS) used when resizing and/or creating Cells. | |
| busyOffset | back to summary |
|---|---|
| private static final long busyOffset | |
| cells | back to summary |
|---|---|
| pack-priv transient volatile Striped64. Table of cells. When non-null, size is a power of 2. | |
| NCPU | back to summary |
|---|---|
| pack-priv static final int NCPU Number of CPUS, to place bound on table size | |
| rng | back to summary |
|---|---|
| pack-priv static final Random rng Generator of new random hash codes | |
| threadHashCode | back to summary |
|---|---|
| pack-priv static final ThreadLocal<@Nullable int[]> threadHashCode ThreadLocal holding a single-slot int array holding hash code. Unlike the JDK8 version of this class, we use a suboptimal int[] representation to avoid introducing a new type that can impede class-unloading when ThreadLocals are not removed. | |
| UNSAFE | back to summary |
|---|---|
| private static final Unsafe UNSAFE | |
| Striped64 | back to summary |
|---|---|
| pack-priv Striped64() Package-private default constructor | |
| casBase | back to summary |
|---|---|
| pack-priv final boolean casBase(long cmp, long val) CASes the base field. | |
| casBusy | back to summary |
|---|---|
| pack-priv final boolean casBusy() CASes the busy field from 0 to 1 to acquire lock. | |
| fn | back to summary |
|---|---|
| pack-priv abstract long fn(long currentValue, long newValue) Computes the function of current and new value. Subclasses should open-code this update function for most uses, but the virtualized form is needed within retryUpdate.
| |
| getUnsafe | back to summary |
|---|---|
| private static Unsafe getUnsafe() Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. Replace with a simple call to Unsafe.getUnsafe when integrating into a jdk.
| |
| internalReset | back to summary |
|---|---|
| pack-priv final void internalReset(long initialValue) Sets base and all cells to the given value. | |
| retryUpdate | back to summary |
|---|---|
| pack-priv final void retryUpdate(long x, int[] hc, boolean wasUncontended) Handles cases of updates involving initialization, resizing, creating new Cells, and/or contention. See above for explanation. This method suffers the usual non-modularity problems of optimistic retry code, relying on rechecked sets of reads.
| |
JVM intrinsics note: It would be possible to use a release-only form of CAS here, if it were provided.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| pack-priv volatile long | |
| private static final Unsafe | |
| pack-priv volatile long | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final boolean |
| p0 | back to summary |
|---|---|
| pack-priv volatile long p0 | |
| p1 | back to summary |
|---|---|
| pack-priv volatile long p1 | |
| p2 | back to summary |
|---|---|
| pack-priv volatile long p2 | |
| p3 | back to summary |
|---|---|
| pack-priv volatile long p3 | |
| p4 | back to summary |
|---|---|
| pack-priv volatile long p4 | |
| p5 | back to summary |
|---|---|
| pack-priv volatile long p5 | |
| p6 | back to summary |
|---|---|
| pack-priv volatile long p6 | |
| q0 | back to summary |
|---|---|
| pack-priv volatile long q0 | |
| q1 | back to summary |
|---|---|
| pack-priv volatile long q1 | |
| q2 | back to summary |
|---|---|
| pack-priv volatile long q2 | |
| q3 | back to summary |
|---|---|
| pack-priv volatile long q3 | |
| q4 | back to summary |
|---|---|
| pack-priv volatile long q4 | |
| q5 | back to summary |
|---|---|
| pack-priv volatile long q5 | |
| q6 | back to summary |
|---|---|
| pack-priv volatile long q6 | |
| UNSAFE | back to summary |
|---|---|
| private static final Unsafe UNSAFE | |
| value | back to summary |
|---|---|
| pack-priv volatile long value | |
| valueOffset | back to summary |
|---|---|
| private static final long valueOffset | |
| Cell | back to summary |
|---|---|
| pack-priv Cell(long x) | |
| cas | back to summary |
|---|---|
| pack-priv final boolean cas(long cmp, long val) | |