Module methanol

Class Prefetcher

java.lang.Object
com.github.mizosoft.methanol.internal.flow.Prefetcher

public final class Prefetcher extends Object
An object that manages requests to an upstream subscription according to a prefetching policy. Callers call initialize(Upstream) when they first receive the subscription and update(Upstream) when a received item is consumed. The prefetching policy ensures that the number of requested but not fulfilled items remains between two values, namely prefetchThreshold and prefetch.

This class is not thread-safe. Caller must ensure that initialize(Upstream) & update(Upstream) are not interleaved and are properly synchronized.

  • Constructor Details

    • Prefetcher

      public Prefetcher()
    • Prefetcher

      public Prefetcher(int prefetch, int prefetchThreshold)
  • Method Details

    • initialize

      public void initialize(Upstream upstream)
    • update

      public void update(Upstream upstream)