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

public Class SubscriptionArbiter

extends AtomicInteger
implements Subscription
Class Inheritance
All Implemented Interfaces
org.reactivestreams.Subscription
Known Direct Subclasses
io.reactivex.internal.operators.flowable.FlowableConcatArray.ConcatArraySubscriber, io.reactivex.internal.operators.flowable.FlowableConcatMap.ConcatMapInner, io.reactivex.internal.operators.flowable.FlowableRepeatWhen.WhenSourceSubscriber, io.reactivex.internal.operators.flowable.FlowableTimeout.TimeoutFallbackSubscriber, io.reactivex.internal.operators.flowable.FlowableTimeoutTimed.TimeoutFallbackSubscriber, io.reactivex.internal.operators.flowable.FlowableOnErrorNext.OnErrorNextSubscriber
Imports
java.util.concurrent.atomic.*, org.reactivestreams.Subscription, io.reactivex.internal.functions.ObjectHelper, io.reactivex.internal.util.BackpressureHelper

Arbitrates requests and cancellation between Subscriptions.

Field Summary

Modifier and TypeField and Description
pack-priv Subscription
actual

The current subscription which may null if no Subscriptions have been set.

pack-priv volatile boolean
pack-priv final boolean
pack-priv final AtomicLong
pack-priv final AtomicLong
pack-priv final AtomicReference<Subscription>
pack-priv long
requested

The current outstanding request amount.

private static final long
protected boolean

Constructor Summary

AccessConstructor and Description
public
SubscriptionArbiter(boolean cancelOnReplace)

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Implements org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.
pack-priv final void
pack-priv final void
public final boolean

Returns:

true if the arbiter has been cancelled
isCancelled
()

Returns true if the arbiter has been cancelled.

public final boolean

Returns:

true if the arbiter runs in unbounded mode
isUnbounded
()

Returns true if the arbiter runs in unbounded mode.

public final void
produced(long n)

public final 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.
public final void
setSubscription(Subscription
the subscription to set, not null (verified)
s
)

Atomically sets a new subscription.

Inherited from java.util.concurrent.atomic.AtomicInteger:
accumulateAndGetaddAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetdecrementAndGetdoubleValuefloatValuegetgetAcquiregetAndAccumulategetAndAddgetAndDecrementgetAndIncrementgetAndSetgetAndUpdategetOpaquegetPlainincrementAndGetintValuelazySetlongValuesetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

actualback to summary
pack-priv Subscription actual

The current subscription which may null if no Subscriptions have been set.

cancelledback to summary
pack-priv volatile boolean cancelled
cancelOnReplaceback to summary
pack-priv final boolean cancelOnReplace
missedProducedback to summary
pack-priv final AtomicLong missedProduced
missedRequestedback to summary
pack-priv final AtomicLong missedRequested
missedSubscriptionback to summary
pack-priv final AtomicReference<Subscription> missedSubscription
requestedback to summary
pack-priv long requested

The current outstanding request amount.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicInteger.serialVersionUID.

unboundedback to summary
protected boolean unbounded

Constructor Detail

SubscriptionArbiterback to summary
public SubscriptionArbiter(boolean cancelOnReplace)

Method Detail

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
drainback to summary
pack-priv final void drain()
drainLoopback to summary
pack-priv final void drainLoop()
isCancelledback to summary
public final boolean isCancelled()

Returns true if the arbiter has been cancelled.

Returns:boolean

true if the arbiter has been cancelled

isUnboundedback to summary
public final boolean isUnbounded()

Returns true if the arbiter runs in unbounded mode.

Returns:boolean

true if the arbiter runs in unbounded mode

producedback to summary
public final void produced(long n)
requestback to summary
public final 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
setSubscriptionback to summary
public final void setSubscription(Subscription s)

Atomically sets a new subscription.

Parameters
s:Subscription

the subscription to set, not null (verified)