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

public final Class ScalarSubscription<T>

extends AtomicInteger
implements QueueSubscription<T>
Class Inheritance
All Implemented Interfaces
io.reactivex.rxjava3.operators.QueueSubscription, org.reactivestreams.Subscription, io.reactivex.rxjava3.operators.QueueFuseable, io.reactivex.rxjava3.operators.SimpleQueue
Type Parameters
<T>
the value type
Imports
java.util.concurrent.atomic.AtomicInteger, org.reactivestreams.Subscriber, io.reactivex.rxjava3.annotations.Nullable, io.reactivex.rxjava3.operators.QueueSubscription

A Subscription that holds a constant value and emits it only when requested.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
CANCELLED

Cancel has been called.

pack-priv static final int
NO_REQUEST

No request has been issued yet.

pack-priv static final int
REQUESTED

Request has been called.

private static final long
pack-priv final Subscriber<? super T>
subscriber

The actual subscriber.

pack-priv final T
value

Hides java.util.concurrent.atomic.AtomicInteger.value.

The single value to emit, set to null.

Constructor Summary

AccessConstructor and Description
public
ScalarSubscription(Subscriber<? super T> subscriber, T value)

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.
public void
clear()

Implements io.reactivex.rxjava3.operators.SimpleQueue.clear.

Removes all enqueued items from this queue.
public boolean

Returns:

true if this Subscription was cancelled
isCancelled
()

Returns true if this Subscription was cancelled.

public boolean
isEmpty()

Implements io.reactivex.rxjava3.operators.SimpleQueue.isEmpty.

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

Implements io.reactivex.rxjava3.operators.SimpleQueue.offer.

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

Implements io.reactivex.rxjava3.operators.SimpleQueue.offer.

Atomically enqueue two values.
public T
poll()

Implements io.reactivex.rxjava3.operators.SimpleQueue.poll.

Tries to dequeue a value (non-null) or returns null if the queue is empty.
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.
public int
requestFusion(int
the requested fusion mode, allowed values are SYNC, ASYNC, ANY combined with BOUNDARY (e.g., requestFusion(SYNC | BOUNDARY)).
mode
)

Implements io.reactivex.rxjava3.operators.QueueFuseable.requestFusion.

Request a fusion mode from the upstream.
Inherited from java.util.concurrent.atomic.AtomicInteger:
accumulateAndGetaddAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetdecrementAndGetdoubleValuefloatValuegetgetAcquiregetAndAccumulategetAndAddgetAndDecrementgetAndIncrementgetAndSetgetAndUpdategetOpaquegetPlainincrementAndGetintValuelazySetlongValuesetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

CANCELLEDback to summary
pack-priv static final int CANCELLED

Cancel has been called.

NO_REQUESTback to summary
pack-priv static final int NO_REQUEST

No request has been issued yet.

REQUESTEDback to summary
pack-priv static final int REQUESTED

Request has been called.

serialVersionUIDback to summary
private static final long serialVersionUID

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

subscriberback to summary
pack-priv final Subscriber<? super T> subscriber

The actual subscriber.

valueback to summary
pack-priv final T value

Hides java.util.concurrent.atomic.AtomicInteger.value.

The single value to emit, set to null.

Constructor Detail

ScalarSubscriptionback to summary
public ScalarSubscription(Subscriber<? super T> subscriber, T value)

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
clearback to summary
public void clear()

Implements io.reactivex.rxjava3.operators.SimpleQueue.clear.

Doc from io.reactivex.rxjava3.operators.SimpleQueue.clear.

Removes all enqueued items from this queue.

Annotations
@Override
isCancelledback to summary
public boolean isCancelled()

Returns true if this Subscription was cancelled.

Returns:boolean

true if this Subscription was cancelled

isEmptyback to summary
public boolean isEmpty()

Implements io.reactivex.rxjava3.operators.SimpleQueue.isEmpty.

Doc from io.reactivex.rxjava3.operators.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 boolean offer(T e)

Implements io.reactivex.rxjava3.operators.SimpleQueue.offer.

Doc from io.reactivex.rxjava3.operators.SimpleQueue.offer.

Atomically enqueue a single value.

Parameters
e:T

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 boolean offer(T v1, T v2)

Implements io.reactivex.rxjava3.operators.SimpleQueue.offer.

Doc from io.reactivex.rxjava3.operators.SimpleQueue.offer.

Atomically enqueue two values.

Parameters
v1:T

the first value to enqueue, not null

v2:T

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
pollback to summary
public T poll()

Implements io.reactivex.rxjava3.operators.SimpleQueue.poll.

Doc from io.reactivex.rxjava3.operators.SimpleQueue.poll.

Tries to dequeue a value (non-null) or returns null if the queue is empty.

If the producer uses offer(Object, Object) and when polling in pairs, if the first poll() returns a non-null item, the second poll() is guaranteed to return a non-null item as well.

Returns:T

the item or null to indicate an empty queue

Annotations
@Nullable
@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
requestFusionback to summary
public int requestFusion(int mode)

Implements io.reactivex.rxjava3.operators.QueueFuseable.requestFusion.

Doc from io.reactivex.rxjava3.operators.QueueFuseable.requestFusion.

Request a fusion mode from the upstream.

This should be called before onSubscribe returns.

Calling this method multiple times or after onSubscribe finished is not allowed and may result in undefined behavior.

Parameters
mode:int

the requested fusion mode, allowed values are SYNC, ASYNC, ANY combined with BOUNDARY (e.g., requestFusion(SYNC | BOUNDARY)).

Returns:int

the established fusion mode: NONE, SYNC, ASYNC.

Annotations
@Override