Interface BlockingStack<N>

  • All Superinterfaces:
    Stack<N>
    All Known Implementing Classes:
    ConcurrentStack

    public interface BlockingStack<N>
    extends Stack<N>
    Created by jcairns on 2/16/16.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      N pop​(long time, java.util.concurrent.TimeUnit unit)
      Pop an element from the stack, waiting if necessary if the stack is currently empty
      N popInterruptibly()
      Pop an element from the stack, waiting as long as required for an element to become available on the stack
      boolean push​(N n, long time, java.util.concurrent.TimeUnit unit)
      Push an element on the stack, waiting if necessary if the stack is currently full
      void pushInterruptibly​(N n)
      Push an element on the stack waiting as long as required for space to become available
    • Method Detail

      • push

        boolean push​(N n,
                     long time,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
        Push an element on the stack, waiting if necessary if the stack is currently full
        Parameters:
        n - - the element to push on the stack
        time - - the maximum time to wait
        unit - - unit of waiting time
        Returns:
        boolean - true if item was pushed, false otherwise
        Throws:
        java.lang.InterruptedException - on interrupt
      • pushInterruptibly

        void pushInterruptibly​(N n)
                        throws java.lang.InterruptedException
        Push an element on the stack waiting as long as required for space to become available
        Parameters:
        n - - the element to push
        Throws:
        java.lang.InterruptedException - - in the event the current thread is interrupted prior to pushing the element
      • pop

        N pop​(long time,
              java.util.concurrent.TimeUnit unit)
        throws java.lang.InterruptedException
        Pop an element from the stack, waiting if necessary if the stack is currently empty
        Parameters:
        time - - the maximum time to wait
        unit - - the time unit for the waiting time
        Returns:
        N - the popped element, or null in the event of a timeout
        Throws:
        java.lang.InterruptedException - on interrupt
      • popInterruptibly

        N popInterruptibly()
                    throws java.lang.InterruptedException
        Pop an element from the stack, waiting as long as required for an element to become available on the stack
        Returns:
        N - the popped element
        Throws:
        java.lang.InterruptedException - - in the event the current thread is interrupted prior to popping any element