Class BoundedBuffer.RingBuffer<E>
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.BBHeader.PadReadCounter
-
- com.github.benmanes.caffeine.cache.BBHeader.ReadCounterRef
-
- com.github.benmanes.caffeine.cache.BBHeader.PadWriteCounter
-
- com.github.benmanes.caffeine.cache.BBHeader.ReadAndWriteCounterRef
-
- com.github.benmanes.caffeine.cache.BoundedBuffer.RingBuffer<E>
-
- All Implemented Interfaces:
Buffer<E>
- Enclosing class:
- BoundedBuffer<E>
static final class BoundedBuffer.RingBuffer<E> extends BBHeader.ReadAndWriteCounterRef implements Buffer<E>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.atomic.AtomicReferenceArray<E>
buffer
-
Fields inherited from class com.github.benmanes.caffeine.cache.BBHeader.ReadAndWriteCounterRef
WRITE_OFFSET, writeCounter
-
Fields inherited from class com.github.benmanes.caffeine.cache.BBHeader.PadWriteCounter
p20, p21, p22, p23, p24, p25, p26, p27, p30, p31, p32, p33, p34, p35, p36
-
Fields inherited from class com.github.benmanes.caffeine.cache.BBHeader.ReadCounterRef
READ_OFFSET, readCounter
-
-
Constructor Summary
Constructors Constructor Description RingBuffer(E e)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
drainTo(java.util.function.Consumer<E> consumer)
Drains the buffer, sending each element to the consumer for processing.int
offer(E e)
Inserts the specified element into this buffer if it is possible to do so immediately without violating capacity restrictions.int
reads()
Returns the number of elements that have been read from the buffer.int
writes()
Returns the number of elements that have been written to the buffer.-
Methods inherited from class com.github.benmanes.caffeine.cache.BBHeader.ReadAndWriteCounterRef
casWriteCounter, relaxedWriteCounter
-
Methods inherited from class com.github.benmanes.caffeine.cache.BBHeader.ReadCounterRef
lazySetReadCounter
-
-
-
-
Field Detail
-
buffer
final java.util.concurrent.atomic.AtomicReferenceArray<E> buffer
-
-
Constructor Detail
-
RingBuffer
public RingBuffer(E e)
-
-
Method Detail
-
offer
public int offer(E e)
Description copied from interface:Buffer
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.
-
drainTo
public void drainTo(java.util.function.Consumer<E> consumer)
Description copied from interface:Buffer
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.
-
reads
public int reads()
Description copied from interface:Buffer
Returns the number of elements that have been read from the buffer.
-
-