Module methanol
Class AbstractPollableSubscription<T>
java.lang.Object
com.github.mizosoft.methanol.internal.flow.AbstractSubscription<T>
com.github.mizosoft.methanol.internal.flow.AbstractPollableSubscription<T>
- All Implemented Interfaces:
Flow.Subscription
- Direct Known Subclasses:
AbstractQueueSubscription
A subscription that emits items from a pollable source.
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractPollableSubscription
(Flow.Subscriber<? super T> downstream, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptionprotected long
emit
(Flow.Subscriber<? super T> downstream, long emit) Emits at mostemit
items to downstream usingAbstractSubscription.submitOnNext(Subscriber, Object)
as long as it returnstrue
.protected abstract boolean
Returnstrue
if downstream is to be completed.protected abstract @Nullable T
poll()
Returns the next item, ornull
if no items are available.Methods inherited from class com.github.mizosoft.methanol.internal.flow.AbstractSubscription
abort, cancel, cancelOnComplete, cancelOnError, currentDemand, fireOrKeepAlive, fireOrKeepAliveOnError, fireOrKeepAliveOnNext, hasPendingErrors, isCancelled, request, submitOnNext
-
Constructor Details
-
AbstractPollableSubscription
-
-
Method Details
-
poll
Returns the next item, ornull
if no items are available. -
isComplete
protected abstract boolean isComplete()Returnstrue
if downstream is to be completed. Implementation must ensuretrue
isn't returned unless the subscription knows it won't produce any more items AND there aren't any present items expected to bepolled
. -
emit
Description copied from class:AbstractSubscription
Emits at mostemit
items to downstream usingAbstractSubscription.submitOnNext(Subscriber, Object)
as long as it returnstrue
. The actual number of emitted items is returned, may be 0 in case of cancellation or if no items are emitted, perhaps due to lack thereof, or ifemit
itself is zero. If the underlying source is finished, the subscriber is completed withAbstractSubscription.cancelOnComplete(Subscriber)
.- Specified by:
emit
in classAbstractSubscription<T>
-