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

public abstract class AbstractPollableSubscription<T> extends AbstractSubscription<T>
A subscription that emits items from a pollable source.
  • Constructor Details

    • AbstractPollableSubscription

      protected AbstractPollableSubscription(Flow.Subscriber<? super T> downstream, Executor executor)
  • Method Details

    • poll

      protected abstract @Nullable T poll()
      Returns the next item, or null if no items are available.
    • isComplete

      protected abstract boolean isComplete()
      Returns true if downstream is to be completed. Implementation must ensure true isn't returned unless the subscription knows it won't produce any more items AND there aren't any present items expected to be polled.
    • emit

      protected long emit(Flow.Subscriber<? super T> downstream, long emit)
      Description copied from class: AbstractSubscription
      Emits at most emit items to downstream using AbstractSubscription.submitOnNext(Subscriber, Object) as long as it returns true. 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 if emit itself is zero. If the underlying source is finished, the subscriber is completed with AbstractSubscription.cancelOnComplete(Subscriber).
      Specified by:
      emit in class AbstractSubscription<T>