Class ObservableReplay.BoundedReplayBuffer<T>
java.lang.Object
java.util.concurrent.atomic.AtomicReference<ObservableReplay.Node>
io.reactivex.rxjava3.internal.operators.observable.ObservableReplay.BoundedReplayBuffer<T>
- Type Parameters:
T
- the value type
- All Implemented Interfaces:
ObservableReplay.ReplayBuffer<T>
,Serializable
- Direct Known Subclasses:
ObservableReplay.SizeAndTimeBoundReplayBuffer
,ObservableReplay.SizeBoundReplayBuffer
- Enclosing class:
ObservableReplay<T>
abstract static class ObservableReplay.BoundedReplayBuffer<T>
extends AtomicReference<ObservableReplay.Node>
implements ObservableReplay.ReplayBuffer<T>
Base class for bounded buffering with options to specify an
enter and leave transforms and custom truncation behavior.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final boolean
private static final long
(package private) int
(package private) ObservableReplay.Node
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final void
Add a new node to the linked list.(package private) final void
collect
(Collection<? super T> output) final void
complete()
Adds a completion event to the buffer.(package private) Object
enterTransform
(Object value) Override this to wrap the NotificationLite object into a container to be used later by truncate.final void
Adds a terminal exception to the buffer.(package private) ObservableReplay.Node
getHead()
(package private) boolean
(package private) boolean
hasError()
(package private) Object
leaveTransform
(Object value) Override this to unwrap the transformed value into a NotificationLite object.final void
Adds a regular value to the buffer.(package private) final void
Remove the first node from the linked list.(package private) final void
removeSome
(int n) final void
replay
(ObservableReplay.InnerDisposable<T> output) Tries to replay the buffered values to the subscriber inside the output if there is new value and requests available at the same time.(package private) final void
Arranges the given node is the new head from now on.(package private) final void
trimHead()
(package private) abstract void
truncate()
Override this method to truncate a non-terminated buffer based on its current properties.(package private) void
Override this method to truncate a terminated buffer based on its properties (i.e., truncate but the very last node).Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
tail
-
size
int size -
eagerTruncate
final boolean eagerTruncate
-
-
Constructor Details
-
BoundedReplayBuffer
BoundedReplayBuffer(boolean eagerTruncate)
-
-
Method Details
-
addLast
Add a new node to the linked list.- Parameters:
n
- the Node instance to add as last
-
removeFirst
final void removeFirst()Remove the first node from the linked list. -
trimHead
final void trimHead() -
removeSome
final void removeSome(int n) -
setFirst
Arranges the given node is the new head from now on.- Parameters:
n
- the Node instance to set as first
-
next
Description copied from interface:ObservableReplay.ReplayBuffer
Adds a regular value to the buffer.- Specified by:
next
in interfaceObservableReplay.ReplayBuffer<T>
- Parameters:
value
- the value to be stored in the buffer
-
error
Description copied from interface:ObservableReplay.ReplayBuffer
Adds a terminal exception to the buffer.- Specified by:
error
in interfaceObservableReplay.ReplayBuffer<T>
- Parameters:
e
- the error to be stored in the buffer
-
complete
public final void complete()Description copied from interface:ObservableReplay.ReplayBuffer
Adds a completion event to the buffer.- Specified by:
complete
in interfaceObservableReplay.ReplayBuffer<T>
-
replay
Description copied from interface:ObservableReplay.ReplayBuffer
Tries to replay the buffered values to the subscriber inside the output if there is new value and requests available at the same time.- Specified by:
replay
in interfaceObservableReplay.ReplayBuffer<T>
- Parameters:
output
- the receiver of the buffered events
-
enterTransform
Override this to wrap the NotificationLite object into a container to be used later by truncate.- Parameters:
value
- the value to transform into the internal representation- Returns:
- the transformed value
-
leaveTransform
Override this to unwrap the transformed value into a NotificationLite object.- Parameters:
value
- the value in the internal representation to transform- Returns:
- the transformed value
-
truncate
abstract void truncate()Override this method to truncate a non-terminated buffer based on its current properties. -
truncateFinal
void truncateFinal()Override this method to truncate a terminated buffer based on its properties (i.e., truncate but the very last node). -
collect
-
hasError
boolean hasError() -
hasCompleted
boolean hasCompleted() -
getHead
ObservableReplay.Node getHead()
-