Package rx.internal.operators
Class OperatorReplay.BoundedReplayBuffer<T>
java.lang.Object
java.util.concurrent.atomic.AtomicReference<OperatorReplay.Node>
rx.internal.operators.OperatorReplay.BoundedReplayBuffer<T>
- Type Parameters:
T- the value type
- All Implemented Interfaces:
Serializable,OperatorReplay.ReplayBuffer<T>
- Direct Known Subclasses:
OperatorReplay.SizeAndTimeBoundReplayBuffer,OperatorReplay.SizeBoundReplayBuffer
- Enclosing class:
OperatorReplay<T>
static class OperatorReplay.BoundedReplayBuffer<T>
extends AtomicReference<OperatorReplay.Node>
implements OperatorReplay.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) longThe total number of received values so far.(package private) final NotificationLite<T> private static final long(package private) int(package private) OperatorReplay.Node -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final voidAdd a new node to the linked list.(package private) final voidcollect(Collection<? super T> output) final voidcomplete()Adds a completion event to the buffer(package private) ObjectenterTransform(Object value) Override this to wrap the NotificationLite object into a container to be used later by truncate.final voidAdds a terminal exception to the buffer(package private) OperatorReplay.NodeReturns the current head for initializing the replay location for a new subscriber.(package private) boolean(package private) booleanhasError()(package private) ObjectleaveTransform(Object value) Override this to unwrap the transformed value into a NotificationLite object.final voidAdds a regular value to the buffer.(package private) final voidRemove the first node from the linked list.(package private) final voidremoveSome(int n) final voidreplay(OperatorReplay.InnerProducer<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 voidArranges the given node is the new head from now on.(package private) voidtruncate()Override this method to truncate a non-terminated buffer based on its current properties.(package private) voidOverride 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:
-
nl
-
tail
OperatorReplay.Node tail -
size
int size -
index
long indexThe total number of received values so far.
-
-
Constructor Details
-
BoundedReplayBuffer
public BoundedReplayBuffer()
-
-
Method Details
-
addLast
Add a new node to the linked list.- Parameters:
n-
-
removeFirst
final void removeFirst()Remove the first node from the linked list. -
removeSome
final void removeSome(int n) -
setFirst
Arranges the given node is the new head from now on.- Parameters:
n-
-
getInitialHead
OperatorReplay.Node getInitialHead()Returns the current head for initializing the replay location for a new subscriber. Override it to consider linked but outdated elements.- Returns:
- the current head
-
next
Description copied from interface:OperatorReplay.ReplayBufferAdds a regular value to the buffer.- Specified by:
nextin interfaceOperatorReplay.ReplayBuffer<T>- Parameters:
value-
-
error
Description copied from interface:OperatorReplay.ReplayBufferAdds a terminal exception to the buffer- Specified by:
errorin interfaceOperatorReplay.ReplayBuffer<T>- Parameters:
e-
-
complete
public final void complete()Description copied from interface:OperatorReplay.ReplayBufferAdds a completion event to the buffer- Specified by:
completein interfaceOperatorReplay.ReplayBuffer<T>
-
replay
Description copied from interface:OperatorReplay.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 interfaceOperatorReplay.ReplayBuffer<T>- Parameters:
output-
-
enterTransform
Override this to wrap the NotificationLite object into a container to be used later by truncate.- Parameters:
value-- Returns:
-
leaveTransform
Override this to unwrap the transformed value into a NotificationLite object.- Parameters:
value-- Returns:
-
truncate
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()
-