E
- The type of elements to add and serve from the queue.@ThreadSafety(level=THREAD_SAFE, doc="By Design") @Status(stage=PRODUCTION, unitTests=COMPLETE) public class CQueue<E> extends Object
ArrayBlockingQueue
but this resulted in dead
locks. It turns out that this class is difficult to use in combination with
synchronized methods. Still: When you don't need the extra functionality in
this class, directly use an ArrayBlockingQueue. The extra functionality
includes: Gathering statistical information plus a standard way to close a
queue.Constructor and Description |
---|
CQueue(int capacity)
Creates a queue with the supplied maximum capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Adds the supplied element to the end of the queue.
|
void |
close()
Closes the queue.
|
int |
getMaximumUsedCapacity()
Gets the maximum used capacity of this CQueue (this equals the maximum
number of elements that have been waiting to be served).
|
E |
serve()
Serve an element waiting in the queue.
|
String |
toString()
Creates a String representation of this CQueue.
|
public CQueue(int capacity)
capacity
- The maximum capacity of this CQueue.IllegalArgumentException
- When the supplied maximum capacity is
less than one.public int getMaximumUsedCapacity()
public void add(E element)
element
- Element to be added to the queue.IllegalStateException
- When the queue is closed.NullPointerException
- When the supplied element is null.public E serve()
public void close()
Copyright © 2008–2018. All rights reserved.