Note that the class leaks all methods of java..
Use complete(Object) to signal the single value.
The this atomic integer stores a bit field:
bit 0: indicates that there is a value available
bit 1: indicates that there was a request made
bit 2: indicates there was a cancellation, exclusively set
bit 3: indicates in fusion mode but no value yet, exclusively set
bit 4: indicates in fusion mode and value is available, exclusively set
bit 5: indicates in fusion mode and value has been consumed, exclusively set
Where exclusively set means any other bits are 0 when that bit is set.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | CANCELLED
Indicates the Subscription has been cancelled. |
| protected final Subscriber | downstream
The Subscriber to emit the value to. |
| pack-priv static final int | FUSED_CONSUMED
Indicates this Subscription is in fusion mode and its value has been consumed. |
| pack-priv static final int | FUSED_EMPTY
Indicates this Subscription is in fusion mode and is currently empty. |
| pack-priv static final int | FUSED_READY
Indicates this Subscription is in fusion mode and has a value. |
| pack-priv static final int | HAS_REQUEST_HAS_VALUE
Indicates this Subscription has both request and value. |
| pack-priv static final int | HAS_REQUEST_NO_VALUE
Indicates this Subscription has been requested but there is no value yet. |
| pack-priv static final int | NO_REQUEST_HAS_VALUE
Indicates this Subscription has a value but not requested yet. |
| pack-priv static final int | NO_REQUEST_NO_VALUE
Indicates this Subscription has no value and not requested yet. |
| private static final long | |
| protected T | value
The value is stored here if there is no request yet or in fusion mode.
|
| Access | Constructor and Description |
|---|---|
| public | DeferredScalarSubscription(Subscriber<? super T>
the Subscriber to wrap, not null (not verified) downstream)Creates a DeferredScalarSubscription by wrapping the given Subscriber. |
| Modifier and Type | Method and Description |
|---|---|
| public void | cancel()
Implements org. Publisher to stop sending data and clean up resources.
|
| public final void | clear()
Implements io. |
| public final void | complete(T
the value to signal, not null (not validated) v)Completes this subscription by indicating the given value should be emitted when the first request arrives. |
| public final boolean | Returns: true if this Subscription has been cancelledReturns true if this Subscription has been cancelled. |
| public final boolean | isEmpty()
Implements io. |
| public final T | poll()
Implements io. |
| public final void | request(long
the strictly positive number of elements to requests to the upstream n)PublisherImplements org. Publisher until demand is signaled via this method.
|
| public final int | requestFusion(int mode)
Implements io. |
| public final boolean | Returns: true if the current thread cancelledAtomically sets a cancelled state and returns true if the current thread did it successfully. |
| CANCELLED | back to summary |
|---|---|
| pack-priv static final int CANCELLED Indicates the Subscription has been cancelled. | |
| downstream | back to summary |
|---|---|
| protected final Subscriber<? super T> downstream The Subscriber to emit the value to. | |
| FUSED_CONSUMED | back to summary |
|---|---|
| pack-priv static final int FUSED_CONSUMED Indicates this Subscription is in fusion mode and its value has been consumed. | |
| FUSED_EMPTY | back to summary |
|---|---|
| pack-priv static final int FUSED_EMPTY Indicates this Subscription is in fusion mode and is currently empty. | |
| FUSED_READY | back to summary |
|---|---|
| pack-priv static final int FUSED_READY Indicates this Subscription is in fusion mode and has a value. | |
| HAS_REQUEST_HAS_VALUE | back to summary |
|---|---|
| pack-priv static final int HAS_REQUEST_HAS_VALUE Indicates this Subscription has both request and value. | |
| HAS_REQUEST_NO_VALUE | back to summary |
|---|---|
| pack-priv static final int HAS_REQUEST_NO_VALUE Indicates this Subscription has been requested but there is no value yet. | |
| NO_REQUEST_HAS_VALUE | back to summary |
|---|---|
| pack-priv static final int NO_REQUEST_HAS_VALUE Indicates this Subscription has a value but not requested yet. | |
| NO_REQUEST_NO_VALUE | back to summary |
|---|---|
| pack-priv static final int NO_REQUEST_NO_VALUE Indicates this Subscription has no value and not requested yet. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides io. | |
| value | back to summary |
|---|---|
| protected T value Hides java. The value is stored here if there is no request yet or in fusion mode. | |
| DeferredScalarSubscription | back to summary |
|---|---|
| public DeferredScalarSubscription(Subscriber<? super T> downstream) Creates a DeferredScalarSubscription by wrapping the given Subscriber.
| |
| cancel | back to summary |
|---|---|
| public void cancel() Implements org. Doc from org. Request the Data may still be sent to meet previously signalled demand after calling cancel.
| |
| clear | back to summary |
|---|---|
| public final void clear() Implements io. Doc from io. Removes all enqueued items from this queue.
| |
| complete | back to summary |
|---|---|
| public final void complete(T v) Completes this subscription by indicating the given value should be emitted when the first request arrives. Make sure this is called exactly once.
| |
| isCancelled | back to summary |
|---|---|
| public final boolean isCancelled() Returns true if this Subscription has been cancelled.
| |
| isEmpty | back to summary |
|---|---|
| public final boolean isEmpty() Implements io. Doc from io. Returns true if the queue is empty.
Note however that due to potential fused functions in
| |
| poll | back to summary |
|---|---|
| public final T poll() Implements io. Doc from io. Tries to dequeue a value (non-null) or returns null if the queue is empty.
If the producer uses | |
| request | back to summary |
|---|---|
| public final void request(long n) Implements org. Doc from org. No events will be sent by a
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
Whatever has been requested can be sent by the
A | |
| requestFusion | back to summary |
|---|---|
| public final int requestFusion(int mode) Implements io. Doc from io. Request a fusion mode from the upstream.
This should be called before
Calling this method multiple times or after
| |
| tryCancel | back to summary |
|---|---|
| public final boolean tryCancel() Atomically sets a cancelled state and returns true if the current thread did it successfully.
| |