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

public abstract Class BasicFuseableConditionalSubscriber<T, R>

extends Object
implements ConditionalSubscriber<T>, QueueSubscription<R>
Class Inheritance
All Implemented Interfaces
io.reactivex.internal.fuseable.QueueSubscription, org.reactivestreams.Subscription, io.reactivex.internal.fuseable.QueueFuseable, io.reactivex.internal.fuseable.SimpleQueue, io.reactivex.internal.fuseable.ConditionalSubscriber, io.reactivex.FlowableSubscriber, org.reactivestreams.Subscriber
Known Direct Subclasses
io.reactivex.internal.operators.flowable.FlowableDistinctUntilChanged.DistinctUntilChangedConditionalSubscriber, io.reactivex.internal.operators.flowable.FlowableDoAfterNext.DoAfterConditionalSubscriber, io.reactivex.internal.operators.flowable.FlowableDoOnEach.DoOnEachConditionalSubscriber, io.reactivex.internal.operators.flowable.FlowableFilter.FilterConditionalSubscriber, io.reactivex.internal.operators.flowable.FlowableMap.MapConditionalSubscriber
Type Parameters
<T>
the upstream value type
<R>
the downstream value type
Imports
org.reactivestreams.Subscription, io.reactivex.exceptions.Exceptions, io.reactivex.internal.fuseable.*, io.reactivex.internal.subscriptions.SubscriptionHelper, io.reactivex.plugins.RxJavaPlugins

Base class for a fuseable intermediate subscriber.

Field Summary

Modifier and TypeField and Description
protected boolean
done

Flag indicating no further onXXX event should be accepted.

protected final ConditionalSubscriber<? super R>
downstream

The downstream subscriber.

protected QueueSubscription<T>
qs

The upstream's QueueSubscription if not null.

protected int
sourceMode

Holds the established fusion mode of the upstream.

protected Subscription
upstream

The upstream subscription.

Constructor Summary

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

Construct a BasicFuseableSubscriber 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
cancel()

Implements org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.
public void
clear()

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

Removes all enqueued items from this queue.
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
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 org.reactivestreams.Subscriber.onComplete.

Successful terminal state.
public void
onError(Throwable
the throwable signaled
t
)

Implements org.reactivestreams.Subscriber.onError.

Failed terminal state.
public final void
onSubscribe(Subscription
the Subscription that allows requesting data via Subscription#request(long)
s
)

Implements io.reactivex.FlowableSubscriber.onSubscribe.

Implementors of this method should make sure everything that needs to be visible in onNext(Object) is established before calling Subscription#request(long).
public void
request(long
the strictly positive number of elements to requests to the upstream Publisher
n
)

Implements org.reactivestreams.Subscription.request.

No events will be sent by a Publisher until demand is signaled via this method.
protected final int

Returns:

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

Calls the upstream's QueueSubscription.requestFusion with the mode and saves the established mode in sourceMode if that mode doesn't have the QueueSubscription#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 ConditionalSubscriber<? super R> downstream

The downstream subscriber.

qsback to summary
protected QueueSubscription<T> qs

The upstream's QueueSubscription if not null.

sourceModeback to summary
protected int sourceMode

Holds the established fusion mode of the upstream.

upstreamback to summary
protected Subscription upstream

The upstream subscription.

Constructor Detail

BasicFuseableConditionalSubscriberback to summary
public BasicFuseableConditionalSubscriber(ConditionalSubscriber<? super R> downstream)

Construct a BasicFuseableSubscriber by wrapping the given subscriber.

Parameters
downstream:ConditionalSubscriber<? 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

cancelback to summary
public void cancel()

Implements org.reactivestreams.Subscription.cancel.

Doc from org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.

Data may still be sent to meet previously signalled demand after calling cancel.

Annotations
@Override
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
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

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 org.reactivestreams.Subscriber.onComplete.

Doc from org.reactivestreams.Subscriber.onComplete.

Successful terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

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

Implements org.reactivestreams.Subscriber.onError.

Doc from org.reactivestreams.Subscriber.onError.

Failed terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Parameters
t:Throwable

the throwable signaled

Annotations
@Override
onSubscribeback to summary
public final void onSubscribe(Subscription s)

Implements io.reactivex.FlowableSubscriber.onSubscribe.

Doc from io.reactivex.FlowableSubscriber.onSubscribe.

Implementors of this method should make sure everything that needs to be visible in onNext(Object) is established before calling Subscription#request(long). In practice this means no initialization should happen after the request() call and additional behavior is thread safe in respect to onNext. Invoked after calling Publisher#subscribe(Subscriber).

No data will start flowing until Subscription#request(long) is invoked.

It is the responsibility of this Subscriber instance to call Subscription#request(long) whenever more data is wanted.

The Publisher will send notifications only in response to Subscription#request(long).

Parameters
s:Subscription

Doc from org.reactivestreams.Subscriber.onSubscribe.

the Subscription that allows requesting data via Subscription#request(long)

Annotations
@SuppressWarnings:unchecked
@Override
requestback to summary
public void request(long n)

Implements org.reactivestreams.Subscription.request.

Doc from org.reactivestreams.Subscription.request.

No events will be sent by a Publisher until demand is signaled via this method.

It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more, it may be treated by the Publisher as "effectively unbounded".

Whatever has been requested can be sent by the Publisher so only signal demand for what can be safely handled.

A Publisher can send less than is requested if the stream ends but then must emit either Subscriber#onError(Throwable) or Subscriber#onComplete().

Parameters
n:long

the strictly positive number of elements to requests to the upstream Publisher

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

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

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

Parameters
mode:int

the fusion mode requested

Returns:int

the established fusion mode