Class CountDownCompleter<T>

  • Type Parameters:
    T - object type

    public final class CountDownCompleter<T>
    extends java.lang.Object
    A synchronization utility that defers invocation of a consumer callback until a set number of actions tracked by a long counter complete.

    Each completion is recorded by invoking the countDown method. When the total number of completions is equal to the preset counter value, this instance is marked as completed and the callback invoked by supplying the object held by this instance.

    • Constructor Summary

      Constructors 
      Constructor Description
      CountDownCompleter​(T object, long count, java.util.function.Consumer<T> onCompleteCallback)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void countDown()
      Records a single completion.
      boolean isComplete()
      Returns if this instance has completed.
      T object()
      Returns the object.
      • Methods inherited from class java.lang.Object

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

      • CountDownCompleter

        public CountDownCompleter​(T object,
                                  long count,
                                  java.util.function.Consumer<T> onCompleteCallback)
        Constructor.
        Parameters:
        object - object
        count - total number of times countDown must be invoked for this completer to complete
        onCompleteCallback - callback to invoke when completer is completed
    • Method Detail

      • object

        public T object()
        Returns the object.
        Returns:
        object
      • countDown

        public void countDown()
        Records a single completion.

        If this instance has already completed, this method has no effect

      • isComplete

        public boolean isComplete()
        Returns if this instance has completed.
        Returns:
        true if completed