Module methanol

Class Prefetcher


  • public final class Prefetcher
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      Prefetcher()  
      Prefetcher​(int prefetch, int prefetchThreshold)  
    • Constructor Detail

      • Prefetcher

        public Prefetcher()
      • Prefetcher

        public Prefetcher​(int prefetch,
                          int prefetchThreshold)
    • Method Detail

      • initialize

        public void initialize​(Upstream upstream)
      • update

        public void update​(Upstream upstream)