public final class ConcurrentStack<N> extends Object implements BlockingStack<N>
Date: 7/9/12
| Constructor and Description |
|---|
ConcurrentStack(int size) |
ConcurrentStack(int size,
SpinPolicy spinPolicy)
construct a new stack of given capacity
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
clear the stack - does not null old references
|
boolean |
contains(N n)
Linear search the stack for contains - not an efficient operation
|
boolean |
isEmpty() |
N |
peek()
peek at the top of the stack
|
N |
pop()
pop the next element off the stack
|
N |
pop(long time,
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)
add an element to the stack, failing if the stack is unable to grow
|
boolean |
push(N n,
long time,
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
|
int |
remainingCapacity()
how much available space in the stack
|
int |
size()
Return the size of the stack
|
public ConcurrentStack(int size)
public ConcurrentStack(int size,
SpinPolicy spinPolicy)
size - - the stack sizespinPolicy - - determine the level of cpu aggressiveness in waitingpublic final boolean push(N n, long time, TimeUnit unit) throws InterruptedException
BlockingStackpush in interface BlockingStack<N>n - - the element to push on the stacktime - - the maximum time to waitunit - - unit of waiting timeInterruptedException - on interruptpublic final void pushInterruptibly(N n) throws InterruptedException
BlockingStackpushInterruptibly in interface BlockingStack<N>n - - the element to pushInterruptedException - - in the event the current thread is interrupted prior to pushing the elementpublic final boolean contains(N n)
Stackpublic final boolean push(N n)
public final N peek()
public final N pop()
public final N pop(long time, TimeUnit unit) throws InterruptedException
BlockingStackpop in interface BlockingStack<N>time - - the maximum time to waitunit - - the time unit for the waiting timeInterruptedException - on interruptpublic final N popInterruptibly() throws InterruptedException
BlockingStackpopInterruptibly in interface BlockingStack<N>InterruptedException - - in the event the current thread is interrupted prior to popping any elementpublic final int size()
public final int remainingCapacity()
remainingCapacity in interface Stack<N>public final boolean isEmpty()
Copyright © 2012–2018 Conversant Engineering. All rights reserved.