Class ThrottleLimitResultQueue<T>


  • public class ThrottleLimitResultQueue<T>
    extends java.lang.Object
    An implementation of the ResultQueue that throttles the number of expected results, limiting it to a maximum at any given time.
    Author:
    Dave Syer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidexpect()
      Tell the queue to expect one more result.
      booleanisEmpty() 
      booleanisExpecting() 
      voidput​(T holder) 
      Ttake() 
      • Methods inherited from class java.lang.Object

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

      • ThrottleLimitResultQueue

        public ThrottleLimitResultQueue​(int throttleLimit)
        Parameters:
        throttleLimit - the maximum number of results that can be expected at any given time.
    • Method Detail

      • isEmpty

        public boolean isEmpty()
      • isExpecting

        public boolean isExpecting()
      • expect

        public void expect()
                    throws java.lang.InterruptedException
        Tell the queue to expect one more result. Blocks until a new result is available if already expecting too many (as determined by the throttle limit).
        Throws:
        java.lang.InterruptedException
        See Also:
        ResultQueue.expect()
      • put

        public void put​(T holder)
                 throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • take

        public T take()
               throws java.util.NoSuchElementException,
                      java.lang.InterruptedException
        Throws:
        java.util.NoSuchElementException
        java.lang.InterruptedException