| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | ATTEMPTS
The maximum number of attempts when trying to expand the table. |
| pack-priv static final int | MAXIMUM_TABLE_SIZE
The bound on the table size. |
| pack-priv static final int | NCPU
Number of CPUS. |
| pack-priv volatile @Nullable Buffer | table
Table of buffers. |
| pack-priv static final VarHandle | |
| pack-priv volatile int | tableBusy
Spinlock (locked via CAS) used when resizing and/or creating Buffers. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final boolean | |
| protected abstract Buffer | Returns: a newly created buffer populated with a single elementthe producer's element e)Creates a new buffer instance after resizing to accommodate a producer. |
| public void | drainTo(Consumer<E>
the action to perform on each element consumer)Implements com. |
| pack-priv final int | Returns: Buffer.SUCCESS, Buffer.FAILED, or Buffer.FULLthe element to add e, int the thread's hash h, int the amount to increment by when rehashing increment, boolean false if CAS failed before this call wasUncontended)Handles cases of updates involving initialization, resizing, creating new Buffers, and/or contention. |
| pack-priv static long | |
| public int | offer(E
the element to add e)Implements com. |
| public long | reads()
Implements com. |
| public long | writes()
Implements com. |
| ATTEMPTS | back to summary |
|---|---|
| pack-priv static final int ATTEMPTS The maximum number of attempts when trying to expand the table. | |
| MAXIMUM_TABLE_SIZE | back to summary |
|---|---|
| pack-priv static final int MAXIMUM_TABLE_SIZE The bound on the table size. | |
| NCPU | back to summary |
|---|---|
| pack-priv static final int NCPU Number of CPUS. | |
| table | back to summary |
|---|---|
| pack-priv volatile @Nullable Buffer<E>[] table Table of buffers. When non-null, size is a power of 2. | |
| TABLE_BUSY | back to summary |
|---|---|
| pack-priv static final VarHandle TABLE_BUSY | |
| tableBusy | back to summary |
|---|---|
| pack-priv volatile int tableBusy Spinlock (locked via CAS) used when resizing and/or creating Buffers. | |
| StripedBuffer | back to summary |
|---|---|
| pack-priv StripedBuffer() | |
| casTableBusy | back to summary |
|---|---|
| pack-priv final boolean casTableBusy() CASes the tableBusy field from 0 to 1 to acquire lock. | |
| create | back to summary |
|---|---|
| protected abstract Buffer Creates a new buffer instance after resizing to accommodate a producer.
| |
| drainTo | back to summary |
|---|---|
| public void drainTo(Consumer<E> consumer) Implements com. Doc from com. Drains the buffer, sending each element to the consumer for processing. The caller must ensure that a consumer has exclusive read access to the buffer. | |
| expandOrRetry | back to summary |
|---|---|
| pack-priv final int expandOrRetry(E e, int h, int increment, boolean wasUncontended) Handles cases of updates involving initialization, resizing, creating new Buffers, 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.
| |
| mix64 | back to summary |
|---|---|
| pack-priv static long mix64(long z) Computes Stafford variant 13 of 64-bit mix function. | |
| offer | back to summary |
|---|---|
| public int offer(E e) Implements com. Doc from com. Inserts the specified element into this buffer if it is possible to do so immediately without violating capacity restrictions. The addition is allowed to fail spuriously if multiple threads insert concurrently.
| |
| reads | back to summary |
|---|---|
| public long reads() Implements com. Doc from com. Returns the number of elements that have been read from the buffer.
| |
| writes | back to summary |
|---|---|
| public long writes() Implements com. Doc from com. Returns the number of elements that have been written to the buffer.
| |