public class BlockingCircularQueue
extends java.lang.Object
implements java.io.Serializable
Internal use only.
.A circular queue with blocking semantics.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Object |
addLock_ |
private int |
back_ |
private int |
capacity_ |
private int |
front_ |
private java.lang.Object |
getLock_ |
private java.lang.Object[] |
queue_ |
private static long |
serialVersionUID |
private int |
size_ |
| Constructor and Description |
|---|
BlockingCircularQueue()
Create the queue with a capacity of 20
|
BlockingCircularQueue(int capacity)
Create the queue with the specified capacity
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.Object object)
Add an object to the queue.
|
protected void |
assertNotNull(java.lang.String fieldName,
java.lang.Object fieldValue)
Verify that the specified value is not null.
|
void |
clear()
Remove all items from the queue
|
private int |
incrementPosition(int position)
Utility method to increment the position and roll back to zero once we
hit the end.
|
boolean |
isEmpty()
Return true if the collection is empty.
|
java.lang.Object |
next()
Return the next item in the queue.
|
int |
size()
Return the number of objects currently in the collection.
|
java.lang.String |
toString()
Return a string representation of this object.
|
private static final long serialVersionUID
private final java.lang.Object getLock_
private final java.lang.Object addLock_
private final java.lang.Object[] queue_
private final int capacity_
private int size_
private int front_
private int back_
public BlockingCircularQueue()
public BlockingCircularQueue(int capacity)
capacity - The size of the queuepublic void clear()
public boolean add(java.lang.Object object)
object - The object to add.public java.lang.Object next()
private int incrementPosition(int position)
position - The position to incrementpublic int size()
public boolean isEmpty()
public java.lang.String toString()
toString in class java.lang.Objectprotected final void assertNotNull(java.lang.String fieldName,
java.lang.Object fieldValue)
throws DetailedNullPointerException
fieldName - The name of the field to checkfieldValue - The value of the field to checkDetailedNullPointerException - If fieldValue is null