Class FlowableReplay.BoundedReplayBuffer<T>
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<FlowableReplay.Node>
-
- io.reactivex.rxjava3.internal.operators.flowable.FlowableReplay.BoundedReplayBuffer<T>
-
- Type Parameters:
T- the value type
- All Implemented Interfaces:
FlowableReplay.ReplayBuffer<T>,java.io.Serializable
- Direct Known Subclasses:
FlowableReplay.SizeAndTimeBoundReplayBuffer,FlowableReplay.SizeBoundReplayBuffer
- Enclosing class:
- FlowableReplay<T>
abstract static class FlowableReplay.BoundedReplayBuffer<T> extends java.util.concurrent.atomic.AtomicReference<FlowableReplay.Node> implements FlowableReplay.ReplayBuffer<T>
Base class for bounded buffering with options to specify an enter and leave transforms and custom truncation behavior.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleaneagerTruncate(package private) longindexprivate static longserialVersionUID(package private) intsize(package private) FlowableReplay.Nodetail
-
Constructor Summary
Constructors Constructor Description BoundedReplayBuffer(boolean eagerTruncate)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) voidaddLast(FlowableReplay.Node n)Add a new node to the linked list.(package private) voidcollect(java.util.Collection<? super T> output)voidcomplete()Adds a completion event to the buffer.(package private) java.lang.ObjectenterTransform(java.lang.Object value, boolean terminal)Override this to wrap the NotificationLite object into a container to be used later by truncate.voiderror(java.lang.Throwable e)Adds a terminal exception to the buffer.(package private) FlowableReplay.NodegetHead()(package private) booleanhasCompleted()(package private) booleanhasError()(package private) java.lang.ObjectleaveTransform(java.lang.Object value)Override this to unwrap the transformed value into a NotificationLite object.voidnext(T value)Adds a regular value to the buffer.(package private) voidremoveFirst()Remove the first node from the linked list.(package private) voidremoveSome(int n)voidreplay(FlowableReplay.InnerSubscription<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) voidsetFirst(FlowableReplay.Node n)Arranges the given node is the new head from now on.(package private) voidtrimHead()(package private) abstract voidtruncate()Override this method to truncate a non-terminated buffer based on its current properties.(package private) voidtruncateFinal()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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
eagerTruncate
final boolean eagerTruncate
-
tail
FlowableReplay.Node tail
-
size
int size
-
index
long index
-
-
Method Detail
-
addLast
final void addLast(FlowableReplay.Node n)
Add a new node to the linked list.- Parameters:
n- the Node instance to add
-
removeFirst
final void removeFirst()
Remove the first node from the linked list.
-
removeSome
final void removeSome(int n)
-
setFirst
final void setFirst(FlowableReplay.Node n)
Arranges the given node is the new head from now on.- Parameters:
n- the Node instance to set as first
-
next
public final void next(T value)
Description copied from interface:FlowableReplay.ReplayBufferAdds a regular value to the buffer.- Specified by:
nextin interfaceFlowableReplay.ReplayBuffer<T>- Parameters:
value- the next value to store
-
error
public final void error(java.lang.Throwable e)
Description copied from interface:FlowableReplay.ReplayBufferAdds a terminal exception to the buffer.- Specified by:
errorin interfaceFlowableReplay.ReplayBuffer<T>- Parameters:
e- the Throwable instance
-
complete
public final void complete()
Description copied from interface:FlowableReplay.ReplayBufferAdds a completion event to the buffer.- Specified by:
completein interfaceFlowableReplay.ReplayBuffer<T>
-
trimHead
final void trimHead()
-
replay
public final void replay(FlowableReplay.InnerSubscription<T> output)
Description copied from interface:FlowableReplay.ReplayBufferTries 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:
replayin interfaceFlowableReplay.ReplayBuffer<T>- Parameters:
output- the receiver of the events
-
enterTransform
java.lang.Object enterTransform(java.lang.Object value, boolean terminal)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 representationterminal- is this a terminal value?- Returns:
- the transformed value
-
leaveTransform
java.lang.Object leaveTransform(java.lang.Object value)
Override this to unwrap the transformed value into a NotificationLite object.- Parameters:
value- the input value to transform to the external representation- 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
final void collect(java.util.Collection<? super T> output)
-
hasError
boolean hasError()
-
hasCompleted
boolean hasCompleted()
-
getHead
FlowableReplay.Node getHead()
-
-