Modifier and Type | Class and Description |
---|---|
pack-priv static class | Striped64.
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 VarHandle | |
pack-priv transient volatile Striped64. | cells
Table of cells. |
pack-priv transient volatile int | cellsBusy
Spinlock (locked via CAS) used when resizing and/or creating Cells. |
private static final VarHandle | |
pack-priv static final int | NCPU
Number of CPUS, to place bound on table size |
private static final VarHandle |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
pack-priv static final int | advanceProbe(int probe)
Pseudo-randomly advances and records the given probe value for the given thread. |
private static long | |
pack-priv final boolean | |
pack-priv final boolean | |
pack-priv final void | doubleAccumulate(double x, DoubleBinaryOperator fn, boolean wasUncontended, int index)
Same as longAccumulate, but injecting long/double conversions in too many places to sensibly merge with long version, given the low-overhead requirements of this class. |
pack-priv final long | |
pack-priv static final int | |
pack-priv final void | longAccumulate(long
the value x, LongBinaryOperator the update function, or null for add (this convention
avoids the need for an extra field or function in LongAdder). fn, boolean false if CAS failed before call wasUncontended, int thread index from getProbe index)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. |
BASE | back to summary |
---|---|
private static final VarHandle BASE |
cells | back to summary |
---|---|
pack-priv transient volatile Striped64. Table of cells. When non-null, size is a power of 2. |
cellsBusy | back to summary |
---|---|
pack-priv transient volatile int cellsBusy Spinlock (locked via CAS) used when resizing and/or creating Cells. |
CELLSBUSY | back to summary |
---|---|
private static final VarHandle CELLSBUSY |
NCPU | back to summary |
---|---|
pack-priv static final int NCPU Number of CPUS, to place bound on table size |
THREAD_PROBE | back to summary |
---|---|
private static final VarHandle THREAD_PROBE |
Striped64 | back to summary |
---|---|
pack-priv Striped64() Package-private default constructor. |
advanceProbe | back to summary |
---|---|
pack-priv static final int advanceProbe(int probe) Pseudo-randomly advances and records the given probe value for the given thread. Duplicated from ThreadLocalRandom because of packaging restrictions. |
apply | back to summary |
---|---|
private static long apply(DoubleBinaryOperator fn, long v, double x) |
casBase | back to summary |
---|---|
pack-priv final boolean casBase(long cmp, long val) CASes the base field. |
casCellsBusy | back to summary |
---|---|
pack-priv final boolean casCellsBusy() CASes the cellsBusy field from 0 to 1 to acquire lock. |
doubleAccumulate | back to summary |
---|---|
pack-priv final void doubleAccumulate(double x, DoubleBinaryOperator fn, boolean wasUncontended, int index) Same as longAccumulate, but injecting long/double conversions in too many places to sensibly merge with long version, given the low-overhead requirements of this class. So must instead be maintained by copy/paste/adapt. |
getAndSetBase | back to summary |
---|---|
pack-priv final long getAndSetBase(long val) |
getProbe | back to summary |
---|---|
pack-priv static final int getProbe() Returns the probe value for the current thread. Duplicated from ThreadLocalRandom because of packaging restrictions. |
longAccumulate | back to summary |
---|---|
pack-priv final void longAccumulate(long x, LongBinaryOperator fn, boolean wasUncontended, int index) 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.
|
Modifier and Type | Field and Description |
---|---|
pack-priv volatile long | |
private static final VarHandle |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
pack-priv final boolean | |
pack-priv final long | |
pack-priv final void | |
pack-priv final void |
value | back to summary |
---|---|
pack-priv volatile long value |
VALUE | back to summary |
---|---|
private static final VarHandle VALUE |
Cell | back to summary |
---|---|
pack-priv Cell(long x) |
cas | back to summary |
---|---|
pack-priv final boolean cas(long cmp, long val) |
getAndSet | back to summary |
---|---|
pack-priv final long getAndSet(long val) |
reset | back to summary |
---|---|
pack-priv final void reset() |
reset | back to summary |
---|---|
pack-priv final void reset(long identity) |