Top Description Fields Constructors Methods
io.reactivex.internal.observers

public abstract Class BasicFuseableObserver<T, R>

extends Object
implements Observer<T>, QueueDisposable<R>
Class Inheritance
All Implemented Interfaces
io.reactivex.internal.fuseable.QueueDisposable, io.reactivex.disposables.Disposable, io.reactivex.internal.fuseable.QueueFuseable, io.reactivex.internal.fuseable.SimpleQueue, io.reactivex.Observer
Known Direct Subclasses
io.reactivex.internal.operators.observable.ObservableDistinct.DistinctObserver, io.reactivex.internal.operators.observable.ObservableDistinctUntilChanged.DistinctUntilChangedObserver, io.reactivex.internal.operators.observable.ObservableDoAfterNext.DoAfterObserver, io.reactivex.internal.operators.observable.ObservableFilter.FilterObserver, io.reactivex.internal.operators.observable.ObservableMap.MapObserver
Type Parameters
<T>
the upstream value type
<R>
the downstream value type
Imports
io.reactivex.Observer, io.reactivex.disposables.Disposable, io.reactivex.exceptions.Exceptions, io.reactivex.internal.disposables.DisposableHelper, io.reactivex.internal.fuseable.QueueDisposable, io.reactivex.plugins.RxJavaPlugins

Base class for a fuseable intermediate observer.

Field Summary

Modifier and TypeField and Description
protected boolean
done

Flag indicating no further onXXX event should be accepted.

protected final Observer<? super R>
downstream

The downstream subscriber.

protected QueueDisposable<T>
qd

The upstream's QueueDisposable if not null.

protected int
sourceMode

Holds the established fusion mode of the upstream.

protected Disposable
upstream

The upstream subscription.

Constructor Summary

AccessConstructor and Description
public
BasicFuseableObserver(Observer<? super R>
the subscriber, not null (not verified)
downstream
)

Construct a BasicFuseableObserver by wrapping the given subscriber.

Method Summary

Modifier and TypeMethod and Description
protected void
afterDownstream()

Override this to perform actions after the call to actual.onSubscribe(this) happened.

protected boolean

Returns:

true if onSubscribe should continue with the call
beforeDownstream
()

Override this to perform actions before the call actual.onSubscribe(this) happens.

public void
clear()

Implements io.reactivex.internal.fuseable.SimpleQueue.clear.

Removes all enqueued items from this queue.
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
protected final void
fail(Throwable
the throwable to rethrow or signal to the actual subscriber
t
)

Rethrows the throwable if it is a fatal exception or calls onError(Throwable).

public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public boolean
isEmpty()

Implements io.reactivex.internal.fuseable.SimpleQueue.isEmpty.

Returns true if the queue is empty.
public final boolean
offer(R
the value to enqueue, not null
e
)

Implements io.reactivex.internal.fuseable.SimpleQueue.offer.

Atomically enqueue a single.
public final boolean
offer(R
the first value to enqueue, not null
v1
,
R
the second value to enqueue, not null
v2
)

Implements io.reactivex.internal.fuseable.SimpleQueue.offer.

Atomically enqueue two values.
public void
onComplete()

Implements io.reactivex.Observer.onComplete.

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

Implements io.reactivex.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public final void
onSubscribe(Disposable
the Disposable instance whose Disposable#dispose() can be called anytime to cancel the connection
d
)

Implements io.reactivex.Observer.onSubscribe.

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.
protected final int

Returns:

the established fusion mode
transitiveBoundaryFusion
(int
the fusion mode requested
mode
)

Calls the upstream's QueueDisposable.requestFusion with the mode and saves the established mode in sourceMode if that mode doesn't have the QueueDisposable#BOUNDARY flag set.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

doneback to summary
protected boolean done

Flag indicating no further onXXX event should be accepted.

downstreamback to summary
protected final Observer<? super R> downstream

The downstream subscriber.

qdback to summary
protected QueueDisposable<T> qd

The upstream's QueueDisposable if not null.

sourceModeback to summary
protected int sourceMode

Holds the established fusion mode of the upstream.

upstreamback to summary
protected Disposable upstream

The upstream subscription.

Constructor Detail

BasicFuseableObserverback to summary
public BasicFuseableObserver(Observer<? super R> downstream)

Construct a BasicFuseableObserver by wrapping the given subscriber.

Parameters
downstream:Observer<? super R>

the subscriber, not null (not verified)

Method Detail

afterDownstreamback to summary
protected void afterDownstream()

Override this to perform actions after the call to actual.onSubscribe(this) happened.

beforeDownstreamback to summary
protected boolean beforeDownstream()

Override this to perform actions before the call actual.onSubscribe(this) happens.

Returns:boolean

true if onSubscribe should continue with the call

clearback to summary
public void clear()

Implements io.reactivex.internal.fuseable.SimpleQueue.clear.

Doc from io.reactivex.internal.fuseable.SimpleQueue.clear.

Removes all enqueued items from this queue.

Annotations
@Override
disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@Override
failback to summary
protected final void fail(Throwable t)

Rethrows the throwable if it is a fatal exception or calls onError(Throwable).

Parameters
t:Throwable

the throwable to rethrow or signal to the actual subscriber

isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements io.reactivex.internal.fuseable.SimpleQueue.isEmpty.

Doc from io.reactivex.internal.fuseable.SimpleQueue.isEmpty.

Returns true if the queue is empty.

Note however that due to potential fused functions in poll() it is possible this method returns false but then poll() returns null because the fused function swallowed the available item(s).

Returns:boolean

true if the queue is empty

Annotations
@Override
offerback to summary
public final boolean offer(R e)

Implements io.reactivex.internal.fuseable.SimpleQueue.offer.

Doc from io.reactivex.internal.fuseable.SimpleQueue.offer.

Atomically enqueue a single.

Parameters
e:R

the value to enqueue, not null

Returns:boolean

true if successful, false if the value was not enqueued likely due to reaching the queue capacity)

Annotations
@Override
offerback to summary
public final boolean offer(R v1, R v2)

Implements io.reactivex.internal.fuseable.SimpleQueue.offer.

Doc from io.reactivex.internal.fuseable.SimpleQueue.offer.

Atomically enqueue two values.

Parameters
v1:R

the first value to enqueue, not null

v2:R

the second value to enqueue, not null

Returns:boolean

true if successful, false if the value was not enqueued likely due to reaching the queue capacity)

Annotations
@Override
onCompleteback to summary
public void onComplete()

Implements io.reactivex.Observer.onComplete.

Doc from io.reactivex.Observer.onComplete.

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 t)

Implements io.reactivex.Observer.onError.

Doc from io.reactivex.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 onComplete.

Parameters
t:Throwable

the exception encountered by the Observable

Annotations
@Override
onSubscribeback to summary
public final void onSubscribe(Disposable d)

Implements io.reactivex.Observer.onSubscribe.

Doc from io.reactivex.Observer.onSubscribe.

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.

Parameters
d:Disposable

the Disposable instance whose Disposable#dispose() can be called anytime to cancel the connection

Annotations
@SuppressWarnings:unchecked
@Override
transitiveBoundaryFusionback to summary
protected final int transitiveBoundaryFusion(int mode)

Calls the upstream's QueueDisposable.requestFusion with the mode and saves the established mode in sourceMode if that mode doesn't have the QueueDisposable#BOUNDARY flag set.

If the upstream doesn't support fusion (qd is null), the method returns QueueDisposable#NONE.

Parameters
mode:int

the fusion mode requested

Returns:int

the established fusion mode