Top Description Inners Fields Constructors Methods
rx.internal.operators

public abstract Class DeferredScalarSubscriber<T, R>

extends Subscriber<T>
Class Inheritance
Known Direct Subclasses
rx.internal.operators.DeferredScalarSubscriberSafe, rx.internal.operators.OnSubscribeReduceSeed.ReduceSeedSubscriber, rx.internal.operators.OnSubscribeTakeLastOne.TakeLastOneSubscriber
Type Parameters
<T>
the source value type
<R>
the result value type
Imports
java.util.concurrent.atomic.AtomicInteger, rx.*

Base class for Subscribers that consume the entire upstream and signal zero or one element (or an error) in a backpressure honoring fashion.

Store any temporary value in value and indicate there is a value available when completing by setting hasValue. subscribeTo(Observable) to properly setup the link between this and the downstream subscriber.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
DeferredScalarSubscriber.InnerProducer

Redirects the downstream request amount bach to the DeferredScalarSubscriber.

Field Summary

Modifier and TypeField and Description
protected final Subscriber<? super R>
actual

The downstream subscriber.

pack-priv static final int
HAS_REQUEST_HAS_VALUE

Value will be emitted.

pack-priv static final int
HAS_REQUEST_NO_VALUE

Request came first.

protected boolean
hasValue

Indicates there is a value available in value.

pack-priv static final int
NO_REQUEST_HAS_VALUE

Value came first.

pack-priv static final int
NO_REQUEST_NO_VALUE

Initial state.

pack-priv final AtomicInteger
state

The state, see the constants below.

protected R
value

The holder of the single value.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final void
complete()

Signals onCompleted() to the downstream subscriber.

protected final void
complete(R
the value to complete with
value
)

Atomically switches to the terminal state and emits the value if there is a request for it or stores it for retrieval by downstreamRequest(long).

pack-priv final void
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
ex
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public final void
setProducer(Producer
producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from
p
)

Overrides rx.Subscriber.setProducer.

If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber.
pack-priv final void
public final void
subscribeTo(Observable<? extends T>
the source Observable
source
)

Links up with the downstream Subscriber (cancellation, backpressure) and subscribes to the source Observable.

Inherited from rx.Subscriber:
addisUnsubscribedonStartrequestunsubscribe

Field Detail

actualback to summary
protected final Subscriber<? super R> actual

The downstream subscriber.

HAS_REQUEST_HAS_VALUEback to summary
pack-priv static final int HAS_REQUEST_HAS_VALUE

Value will be emitted.

HAS_REQUEST_NO_VALUEback to summary
pack-priv static final int HAS_REQUEST_NO_VALUE

Request came first.

hasValueback to summary
protected boolean hasValue

Indicates there is a value available in value.

NO_REQUEST_HAS_VALUEback to summary
pack-priv static final int NO_REQUEST_HAS_VALUE

Value came first.

NO_REQUEST_NO_VALUEback to summary
pack-priv static final int NO_REQUEST_NO_VALUE

Initial state.

stateback to summary
pack-priv final AtomicInteger state

The state, see the constants below.

valueback to summary
protected R value

The holder of the single value.

Constructor Detail

DeferredScalarSubscriberback to summary
public DeferredScalarSubscriber(Subscriber<? super R> actual)

Method Detail

completeback to summary
protected final void complete()

Signals onCompleted() to the downstream subscriber.

completeback to summary
protected final void complete(R value)

Atomically switches to the terminal state and emits the value if there is a request for it or stores it for retrieval by downstreamRequest(long).

Parameters
value:R

the value to complete with

downstreamRequestback to summary
pack-priv final void downstreamRequest(long n)
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 ex)

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
ex:Throwable

the exception encountered by the Observable

Annotations
@Override
setProducerback to summary
public final void setProducer(Producer p)

Overrides rx.Subscriber.setProducer.

Doc from rx.Subscriber.setProducer.

If other subscriber is set (by calling constructor Subscriber(Subscriber) or Subscriber(Subscriber, boolean)) then this method calls setProducer on the other subscriber. If the other subscriber is not set and no requests have been made to this subscriber then p.request(Long.MAX_VALUE) is called. If the other subscriber is not set and some requests have been made to this subscriber then p.request(n) is called where n is the accumulated requests to this subscriber.

Parameters
p:Producer

producer to be used by this subscriber or the other subscriber (or recursively its other subscriber) to make requests from

Annotations
@Override
setupDownstreamback to summary
pack-priv final void setupDownstream()
subscribeToback to summary
public final void subscribeTo(Observable<? extends T> source)

Links up with the downstream Subscriber (cancellation, backpressure) and subscribes to the source Observable.

Parameters
source:Observable<? extends T>

the source Observable

rx.internal.operators back to summary

pack-priv final Class DeferredScalarSubscriber.InnerProducer

extends Object
implements Producer
Class Inheritance
All Implemented Interfaces
rx.Producer

Redirects the downstream request amount bach to the DeferredScalarSubscriber.

Field Summary

Modifier and TypeField and Description
pack-priv final DeferredScalarSubscriber<?, ?>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
request(long
the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace
n
)

Implements rx.Producer.request.

Request a certain maximum number of items from this Producer.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parentback to summary
pack-priv final DeferredScalarSubscriber<?, ?> parent

Constructor Detail

InnerProducerback to summary
public InnerProducer(DeferredScalarSubscriber<?, ?> parent)

Method Detail

requestback to summary
public void request(long n)

Implements rx.Producer.request.

Doc from rx.Producer.request.

Request a certain maximum number of items from this Producer. This is a way of requesting backpressure. To disable backpressure, pass Long.MAX_VALUE to this method.

Requests are additive but if a sequence of requests totals more than Long.MAX_VALUE then Long.MAX_VALUE requests will be actioned and the extras may be ignored. Arriving at Long.MAX_VALUE by addition of requests cannot be assumed to disable backpressure. For example, the code below may result in Long.MAX_VALUE requests being actioned only.

request(100);
request(Long.MAX_VALUE-1);
Parameters
n:long

the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace

Annotations
@Override