Top Description Inners Fields Constructors Methods
rx.internal.operators

public final Class BufferUntilSubscriber<T>

extends Subject<T, T>
Class Inheritance
Type Parameters
<T>
the type of the items to be buffered
Imports
java.util.concurrent.ConcurrentLinkedQueue, java.util.concurrent.atomic.AtomicReference, rx.*, rx.functions.Action0, rx.subjects.Subject, rx.subscriptions.Subscriptions

A solution to the "time gap" problem that occurs with groupBy and pivot.

This currently has temporary unbounded buffers. It needs to become bounded and then do one of two things:

  1. blow up and make the user do something about it
  2. work with the backpressure solution ... still to be implemented (such as co-routines)

Generally the buffer should be very short lived (milliseconds) and then stops being involved. It can become a memory leak though if a GroupedObservable backed by this class is emitted but never subscribed to (such as filtered out). In that case, either a time-bomb to throw away the buffer, or just blowing up and making the user do something about it is needed.

For example, to filter out GroupedObservables, perhaps they need a silent subscribe() on them to just blackhole the data.

This is an initial start at solving this problem and solves the immediate problem of groupBy and pivot and trades off the possibility of memory leak for deterministic functionality.

See Also
the Github issue describing the time gap problem

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
BufferUntilSubscriber.State<T>

The common state.

Field Summary

Modifier and TypeField and Description
pack-priv static final Observer<T>
private boolean
pack-priv final BufferUntilSubscriber.State<T>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
the value type
T
>
BufferUntilSubscriber<T>

Returns:

the instance
create
()

Creates a default, unbounded buffering Subject instance.

private void
public boolean
hasObservers()

Implements abstract rx.subjects.Subject.hasObservers.

Indicates whether the Subject has Observers subscribed to it.
public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
Inherited from rx.subjects.Subject:
toSerialized

Field Detail

EMPTY_OBSERVERback to summary
pack-priv static final Observer<T> EMPTY_OBSERVER
Annotations
@SuppressWarnings:rawtypes
forwardback to summary
private boolean forward
stateback to summary
pack-priv final BufferUntilSubscriber.State<T> state

Constructor Detail

BufferUntilSubscriberback to summary
private BufferUntilSubscriber(BufferUntilSubscriber.State<T> state)

Method Detail

createback to summary
public static <T> BufferUntilSubscriber<T> create()

Creates a default, unbounded buffering Subject instance.

Parameters
<T>
the value type
Returns:BufferUntilSubscriber<T>

the instance

emitback to summary
private void emit(Object v)
hasObserversback to summary
public boolean hasObservers()

Implements abstract rx.subjects.Subject.hasObservers.

Doc from rx.subjects.Subject.hasObservers.

Indicates whether the Subject has Observers subscribed to it.

Returns:boolean

true if there is at least one Observer subscribed to this Subject, false otherwise

Annotations
@Override
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
rx.internal.operators back to summary

pack-priv final Class BufferUntilSubscriber.OnSubscribeAction<T>

extends Object
implements Observable.OnSubscribe<T>
Class Inheritance
  • java.lang.Object
  • rx.internal.operators.BufferUntilSubscriber.OnSubscribeAction
All Implemented Interfaces
rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action, rx.functions.Function

Field Summary

Modifier and TypeField and Description
pack-priv final BufferUntilSubscriber.State<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
call(final Subscriber<? super T> s)

Implements rx.functions.Action1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

stateback to summary
pack-priv final BufferUntilSubscriber.State<T> state

Constructor Detail

OnSubscribeActionback to summary
public OnSubscribeAction(BufferUntilSubscriber.State<T> state)

Method Detail

callback to summary
public void call(final Subscriber<? super T> s)

Implements rx.functions.Action1.call.

Annotations
@Override
rx.internal.operators back to summary

pack-priv final Class BufferUntilSubscriber.State<T>

extends AtomicReference<Observer<? super T>>
Class Inheritance

The common state.

Field Summary

Modifier and TypeField and Description
pack-priv final ConcurrentLinkedQueue<Object>
pack-priv boolean
pack-priv final Object
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
casObserverRef(Observer<? super T> expected, Observer<? super T> next)

Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

bufferback to summary
pack-priv final ConcurrentLinkedQueue<Object> buffer
emittingback to summary
pack-priv boolean emitting
guardback to summary
pack-priv final Object guard
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

Constructor Detail

Stateback to summary
pack-priv State()

Method Detail

casObserverRefback to summary
pack-priv boolean casObserverRef(Observer<? super T> expected, Observer<? super T> next)