Top Description Inners Fields Constructors Methods
com.github.benmanes.caffeine.cache

pack-priv final Class BoundedBuffer<E>

Additional top-level class in compilation unit: BBHeader.

extends StripedBuffer<E>
Class Inheritance
Type Parameters
<E>
the type of elements maintained by this buffer
Imports
java.lang.invoke.MethodHandles, .VarHandle, java.util.function.Consumer

A striped, non-blocking, bounded buffer.
Author
[email protected] (Ben Manes)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final int
BUFFER_SIZE

The maximum number of elements per buffer.

pack-priv static final int
Inherited from com.github.benmanes.caffeine.cache.StripedBuffer:
ATTEMPTSMAXIMUM_TABLE_SIZENCPUtableTABLE_BUSYtableBusy

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected Buffer<E>
create(E
the producer's element
e
)

Implements abstract com.github.benmanes.caffeine.cache.StripedBuffer.create.

Creates a new buffer instance after resizing to accommodate a producer.
Inherited from com.github.benmanes.caffeine.cache.StripedBuffer:
casTableBusydrainToexpandOrRetrymix64offerreadswrites

Field Detail

BUFFER_SIZEback to summary
pack-priv static final int BUFFER_SIZE

The maximum number of elements per buffer.

MASKback to summary
pack-priv static final int MASK

Constructor Detail

BoundedBufferback to summary
pack-priv BoundedBuffer()

Method Detail

createback to summary
protected Buffer<E> create(E e)

Implements abstract com.github.benmanes.caffeine.cache.StripedBuffer.create.

Doc from com.github.benmanes.caffeine.cache.StripedBuffer.create.

Creates a new buffer instance after resizing to accommodate a producer.

Parameters
e:E

the producer's element

Returns:Buffer<E>

a newly created buffer populated with a single element

Annotations
@Override
com.github.benmanes.caffeine.cache back to summary

pack-priv final Class BoundedBuffer.RingBuffer<E>

extends ReadAndWriteCounterRef
implements Buffer<E>
Class Inheritance
All Implemented Interfaces
com.github.benmanes.caffeine.cache.Buffer

Field Summary

Modifier and TypeField and Description
pack-priv static final VarHandle
pack-priv final Object[]
Inherited from com.github.benmanes.caffeine.cache.BBHeader.ReadAndWriteCounterRef:
READWRITEwriteCounter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
drainTo(Consumer<E>
the action to perform on each element
consumer
)

Implements com.github.benmanes.caffeine.cache.Buffer.drainTo.

Drains the buffer, sending each element to the consumer for processing.
public int
offer(E
the element to add
e
)

Implements com.github.benmanes.caffeine.cache.Buffer.offer.

Inserts the specified element into this buffer if it is possible to do so immediately without violating capacity restrictions.
public long
reads()

Implements com.github.benmanes.caffeine.cache.Buffer.reads.

Returns the number of elements that have been read from the buffer.
public long
writes()

Implements com.github.benmanes.caffeine.cache.Buffer.writes.

Returns the number of elements that have been written to the buffer.
Inherited from com.github.benmanes.caffeine.cache.BBHeader.ReadAndWriteCounterRef:
casWriteCountersetReadCounterOpaquewriteCounterOpaque

Field Detail

BUFFERback to summary
pack-priv static final VarHandle BUFFER
bufferback to summary
pack-priv final Object[] buffer

Constructor Detail

RingBufferback to summary
public RingBuffer(E e)

Method Detail

drainToback to summary
public void drainTo(Consumer<E> consumer)

Implements com.github.benmanes.caffeine.cache.Buffer.drainTo.

Doc from com.github.benmanes.caffeine.cache.Buffer.drainTo.

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.

Parameters
consumer:Consumer<E>

the action to perform on each element

Annotations
@Override
offerback to summary
public int offer(E e)

Implements com.github.benmanes.caffeine.cache.Buffer.offer.

Doc from com.github.benmanes.caffeine.cache.Buffer.offer.

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.

Parameters
e:E

the element to add

Returns:int

Buffer.SUCCESS, Buffer.FAILED, or Buffer.FULL

Annotations
@Override
readsback to summary
public long reads()

Implements com.github.benmanes.caffeine.cache.Buffer.reads.

Doc from com.github.benmanes.caffeine.cache.Buffer.reads.

Returns the number of elements that have been read from the buffer.

Returns:long

the number of elements read from this buffer

Annotations
@Override
writesback to summary
public long writes()

Implements com.github.benmanes.caffeine.cache.Buffer.writes.

Doc from com.github.benmanes.caffeine.cache.Buffer.writes.

Returns the number of elements that have been written to the buffer.

Returns:long

the number of elements written to this buffer

Annotations
@Override