Top Description Fields Constructors Methods
rx.internal.producers

public final Class QueuedValueProducer<T>

extends AtomicLong
implements Producer
Class Inheritance
All Implemented Interfaces
rx.Producer
Type Parameters
<T>
the value type
Imports
java.util.Queue, java.util.concurrent.atomic.*, rx.*, rx.exceptions.*, rx.internal.operators.BackpressureUtils, rx.internal.util.atomic.SpscLinkedAtomicQueue, rx.internal.util.unsafe.*

Producer that holds an unbounded (or custom) queue to enqueue values and relays them to a child subscriber on request.

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super T>
pack-priv static final Object
pack-priv final Queue<Object>
private static final long
pack-priv final AtomicInteger

Constructor Summary

AccessConstructor and Description
public
QueuedValueProducer(Subscriber<? super T>
the target child subscriber
child
)

Constructs an instance with the target child subscriber and an Spsc Linked (Atomic) Queue as the queue implementation.

public
QueuedValueProducer(Subscriber<? super T>
the target child subscriber
child
,
Queue<Object>
the queue to use
queue
)

Constructs an instance with the target child subscriber and a custom queue implementation

Method Summary

Modifier and TypeMethod and Description
private void
public boolean

Returns:

true if the queue accepted the offer, false otherwise
offer
(T
the value to enqueue and attempt to drain
value
)

Offers a value to this producer and tries to emit any queued values if the child requests allow it.

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.util.concurrent.atomic.AtomicLong:
accumulateAndGetaddAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetdecrementAndGetdoubleValuefloatValuegetgetAcquiregetAndAccumulategetAndAddgetAndDecrementgetAndIncrementgetAndSetgetAndUpdategetOpaquegetPlainincrementAndGetintValuelazySetlongValuesetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

childback to summary
pack-priv final Subscriber<? super T> child
NULL_SENTINELback to summary
pack-priv static final Object NULL_SENTINEL
queueback to summary
pack-priv final Queue<Object> queue
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicLong.serialVersionUID.

wipback to summary
pack-priv final AtomicInteger wip

Constructor Detail

QueuedValueProducerback to summary
public QueuedValueProducer(Subscriber<? super T> child)

Constructs an instance with the target child subscriber and an Spsc Linked (Atomic) Queue as the queue implementation.

Parameters
child:Subscriber<? super T>

the target child subscriber

QueuedValueProducerback to summary
public QueuedValueProducer(Subscriber<? super T> child, Queue<Object> queue)

Constructs an instance with the target child subscriber and a custom queue implementation

Parameters
child:Subscriber<? super T>

the target child subscriber

queue:Queue<Object>

the queue to use

Method Detail

drainback to summary
private void drain()
offerback to summary
public boolean offer(T value)

Offers a value to this producer and tries to emit any queued values if the child requests allow it.

Parameters
value:T

the value to enqueue and attempt to drain

Returns:boolean

true if the queue accepted the offer, false otherwise

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