| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final long | |
| pack-priv static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static <T, U> boolean | checkTerminated(boolean d, boolean empty, Subscriber<?> s, boolean delayError, SimpleQueue<?> q, QueueDrain<T, U> qd)
|
| public static <T, U> boolean | checkTerminated(boolean d, boolean empty, Observer<?> observer, boolean delayError, SimpleQueue<?> q, Disposable disposable, ObservableQueueDrain<T, U> qd)
|
| public static < the value type of the queue T> SimpleQueue | Returns: the queue instancethe capacity hint, negative value will create an array-based SPSC queue capacityHint)Creates a queue: spsc-array if capacityHint is positive and spsc-linked-array if capacityHint is negative; in both cases, the capacity is the absolute value of prefetch. |
| public static <T, U> void | drainLoop(SimplePlainQueue<T> q, Observer<? super U> a, boolean delayError, Disposable dispose, ObservableQueueDrain<T, U> qd)
|
| public static < the queue value type T, the emission value type U> void | drainMaxLoop(SimplePlainQueue<T>
the queue q, Subscriber<? super U> the subscriber a, boolean true if errors should be delayed after all normal items delayError, Disposable the disposable to call when termination happens and cleanup is necessary dispose, QueueDrain<T, U> the QueueDrain instance that gives status information to the drain logic qd)Drain the queue but give up with an error if there aren't enough requests. |
| pack-priv static boolean | |
| public static < the value type emitted T> void | postComplete(Subscriber<? super T>
the target Subscriber to send events to actual, Queue<T> the queue to drain if in the post-complete state queue, AtomicLong holds the request amount and the post-completed flag state, BooleanSupplier a supplier that returns true if the drain has been cancelled isCancelled)Signals the completion of the main sequence and switches to post-completion replay mode. |
| pack-priv static <T> boolean | Returns: true if the queue was completely drained or the drain process was cancelledthe current request amount n, Subscriber<? super T> the target Subscriber to send events to actual, Queue<T> the queue to drain if in the post-complete state queue, AtomicLong holds the request amount and the post-completed flag state, BooleanSupplier a supplier that returns true if the drain has been cancelled isCancelled)Drains the queue based on the outstanding requests in post-completed mode (only!). |
| public static < the value type emitted T> boolean | Returns: true if the state indicates a completion state.the request amount, positive (not validated) n, Subscriber<? super T> the target Subscriber to send events to actual, Queue<T> the queue to drain if in the post-complete state queue, AtomicLong holds the request amount and the post-completed flag state, BooleanSupplier a supplier that returns true if the drain has been cancelled isCancelled)Accumulates requests (not validated) and handles the completed mode draining of the queue based on the requests. |
| public static void | request(Subscription
the Subscription to request from s, int the prefetch value prefetch)Requests Long.MAX_VALUE if prefetch is negative or the exact amount if prefetch is positive. |
| COMPLETED_MASK | back to summary |
|---|---|
| pack-priv static final long COMPLETED_MASK | |
| REQUESTED_MASK | back to summary |
|---|---|
| pack-priv static final long REQUESTED_MASK | |
| QueueDrainHelper | back to summary |
|---|---|
| private QueueDrainHelper() Utility class. | |
| checkTerminated | back to summary |
|---|---|
| public static <T, U> boolean checkTerminated(boolean d, boolean empty, Subscriber<?> s, boolean delayError, SimpleQueue<?> q, QueueDrain<T, U> qd) | |
| checkTerminated | back to summary |
|---|---|
| public static <T, U> boolean checkTerminated(boolean d, boolean empty, Observer<?> observer, boolean delayError, SimpleQueue<?> q, Disposable disposable, ObservableQueueDrain<T, U> qd) | |
| createQueue | back to summary |
|---|---|
| public static <T> SimpleQueue Creates a queue: spsc-array if capacityHint is positive and spsc-linked-array if capacityHint is negative; in both cases, the capacity is the absolute value of prefetch.
| |
| drainLoop | back to summary |
|---|---|
| public static <T, U> void drainLoop(SimplePlainQueue<T> q, Observer<? super U> a, boolean delayError, Disposable dispose, ObservableQueueDrain<T, U> qd) | |
| drainMaxLoop | back to summary |
|---|---|
| public static <T, U> void drainMaxLoop(SimplePlainQueue<T> q, Subscriber<? super U> a, boolean delayError, Disposable dispose, QueueDrain<T, U> qd) Drain the queue but give up with an error if there aren't enough requests.
| |
| isCancelled | back to summary |
|---|---|
| pack-priv static boolean isCancelled(BooleanSupplier cancelled) | |
| postComplete | back to summary |
|---|---|
| public static <T> void postComplete(Subscriber<? super T> actual, Queue<T> queue, AtomicLong state, BooleanSupplier isCancelled) Signals the completion of the main sequence and switches to post-completion replay mode. Don't modify the queue after calling this method! Post-completion backpressure handles the case when a source produces values based on requests when it is active but more values are available even after its completion. In this case, the onComplete() can't just emit the contents of the queue but has to coordinate with the requested amounts. This requires two distinct modes: active and completed. In active mode, requests flow through and the queue is not accessed but in completed mode, requests no-longer reach the upstream but help in draining the queue. The algorithm utilizes the most significant bit (bit 63) of a long value (AtomicLong) since request amount only goes up to Long.MAX_VALUE (bits 0-62) and negative values aren't allowed.
| |
| postCompleteDrain | back to summary |
|---|---|
| pack-priv static <T> boolean postCompleteDrain(long n, Subscriber<? super T> actual, Queue<T> queue, AtomicLong state, BooleanSupplier isCancelled) Drains the queue based on the outstanding requests in post-completed mode (only!).
| |
| postCompleteRequest | back to summary |
|---|---|
| public static <T> boolean postCompleteRequest(long n, Subscriber<? super T> actual, Queue<T> queue, AtomicLong state, BooleanSupplier isCancelled) Accumulates requests (not validated) and handles the completed mode draining of the queue based on the requests. Post-completion backpressure handles the case when a source produces values based on requests when it is active but more values are available even after its completion. In this case, the onComplete() can't just emit the contents of the queue but has to coordinate with the requested amounts. This requires two distinct modes: active and completed. In active mode, requests flow through and the queue is not accessed but in completed mode, requests no-longer reach the upstream but help in draining the queue.
| |
| request | back to summary |
|---|---|
| public static void request(Subscription s, int prefetch) Requests Long.MAX_VALUE if prefetch is negative or the exact amount if prefetch is positive.
| |