Class PromiseLatch<T>

java.lang.Object
org.nustaq.kontraktor.util.PromiseLatch<T>

public class PromiseLatch<T> extends Object
Created by ruedi on 27.07.14. Wraps a future and triggers it after having received N results (counter is counted down). Note that only the last result/error is actually transmitteed to the wrapped future. An implementation collecting intermediate results in a concurrentlist which then is used as a result could be implemented if needed. Usually used for pure signaling (so result is "void")
  • Constructor Details

    • PromiseLatch

      public PromiseLatch(IPromise<T> wrapped)
    • PromiseLatch

      public PromiseLatch(int counter, IPromise<T> wrapped)
    • PromiseLatch

      public PromiseLatch(int counter)
    • PromiseLatch

      public PromiseLatch(IPromise<T> wrapped, int counter)
  • Method Details

    • countDown

      public void countDown()
    • countDown

      public void countDown(T result, Object error)
    • isComplete

      public boolean isComplete()
    • countUp

      public void countUp(int amount)
    • getCount

      public int getCount()
      debug, cannot be used to implement reliable logic in a concurrent environment
      Returns:
    • getPromise

      public IPromise<T> getPromise()
    • reject

      public void reject(String err)