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. This class's abstract methods are called
serially, and implementations may assume they're being called from a single thread.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPollableSubscription(Flow.Subscriber<? super T> downstream, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptionprotected longemit(Flow.Subscriber<? super T> downstream, long emit) Emits at mostemititems to downstream usingAbstractSubscription.submitOnNext(Subscriber, Object)as long as it returnstrue.protected abstract booleanReturnstrueif downstream is to be completed.protected abstract @Nullable Tpoll()Returns the next item, ornullif no items are available.Methods inherited from class AbstractSubscription
abort, cancel, cancelOnComplete, cancelOnError, currentDemand, fireOrKeepAlive, fireOrKeepAliveOnError, fireOrKeepAliveOnNext, hasPendingErrors, isCancelled, request, submitOnNext
-
Constructor Details
-
AbstractPollableSubscription
-
-
Method Details
-
poll
Returns the next item, ornullif no items are available. -
isComplete
protected abstract boolean isComplete()Returnstrueif downstream is to be completed. Implementation must ensuretrueisn'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:AbstractSubscriptionEmits at mostemititems 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 ifemititself is zero. If the underlying source is finished, the subscriber is completed withAbstractSubscription.cancelOnComplete(Subscriber).- Specified by:
emitin classAbstractSubscription<T>
-