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 Detail

      • push

        boolean push​(N n,
                     long time,
                     TimeUnit unit)
              throws 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:
        InterruptedException - on interrupt
      • pushInterruptibly

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

        N pop​(long time,
              TimeUnit unit)
        throws 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:
        InterruptedException - on interrupt
      • popInterruptibly

        N popInterruptibly()
                    throws 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:
        InterruptedException - - in the event the current thread is interrupted prior to popping any element