Class LatestItemSequentialProcessor<ItemType>

  • Type Parameters:
    ItemType - The type of item to be processed.

    public class LatestItemSequentialProcessor<ItemType>
    extends java.lang.Object
    Provides a way to run a provided function on items but guarantees that the function is only invoked for one item at a time. If multiple 'updates' to the item are provided while the processor is running, only the most recent is passed to the function. This allows it to 'skip' updates for items that are not the most recent value.
    • Constructor Summary

      Constructors 
      Constructor Description
      LatestItemSequentialProcessor​(java.util.function.Consumer<ItemType> processFunction, java.util.concurrent.Executor executor)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void updateItem​(ItemType newItem)
      Updates the item and triggers it to be processed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LatestItemSequentialProcessor

        public LatestItemSequentialProcessor​(java.util.function.Consumer<ItemType> processFunction,
                                             java.util.concurrent.Executor executor)
    • Method Detail

      • updateItem

        public void updateItem​(ItemType newItem)
        Updates the item and triggers it to be processed.
        Parameters:
        newItem - The item to be processed. (Cannot be null)