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 emptyN
popInterruptibly()
Pop an element from the stack, waiting as long as required for an element to become available on the stackboolean
push(N n, long time, java.util.concurrent.TimeUnit unit)
Push an element on the stack, waiting if necessary if the stack is currently fullvoid
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 stacktime
- - the maximum time to waitunit
- - 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 waitunit
- - 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
-
-