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:
java.util.concurrent.Flow.Subscription
- Direct Known Subclasses:
AbstractQueueSubscription
public abstract class AbstractPollableSubscription<T> extends AbstractSubscription<T>
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
Constructors Modifier Constructor Description protectedAbstractPollableSubscription(java.util.concurrent.Flow.Subscriber<? super T> downstream, java.util.concurrent.Executor executor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected longemit(java.util.concurrent.Flow.Subscriber<? super T> downstream, long emit)Emits at mostemititems to downstream usingAbstractSubscription.submitOnNext( Subscriber, Object)as long as it returnstrue.protected abstract booleanisComplete()Returnstrueif downstream is to be completed.protected abstract @Nullable Tpoll()Returns the next item, ornullif 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 Detail
-
AbstractPollableSubscription
protected AbstractPollableSubscription(java.util.concurrent.Flow.Subscriber<? super T> downstream, java.util.concurrent.Executor executor)
-
-
Method Detail
-
poll
protected abstract @Nullable T 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
protected long emit(java.util.concurrent.Flow.Subscriber<? super T> downstream, long 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>
-
-