|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.util.UnbiasedQueue
@Deprecated public class UnbiasedQueue
A generic queue class. This queue is explicitly NOT a synchronized queue.
FIXME 20020511 bondolo@jxta.org This could be more efficient with a circular queue implementation, but its a pain to write since we allow the queue to be resizable. FIXME 20020511 bondolo@jxta.org Exercise for the reader: Extend this class so that it does both LIFO and FIFO. FIXME 20020910 bondolo@jxta.org Needs an optional listener callback for droppped elments. FIXME 20020910 bondolo@jxta.org Needs an optional "strategy" for element insertion and removal.
Nested Class Summary | |
---|---|
protected static class |
UnbiasedQueue.SynchronizedQueue
Deprecated. An inner class for wrapping arbitrary queues with synchronization. |
Field Summary | |
---|---|
protected boolean |
closeFlag
Deprecated. If true the queue is being closed and is currently in the process of being flushed. |
protected static int |
DEFAULT_MAX_OBJECTS
Deprecated. Default number of queue elements. |
protected static boolean |
DROP_OLDEST_OBJECT
Deprecated. Default object dropping behaviour |
protected boolean |
dropOldestObject
Deprecated. When we need to drop objects, drop the oldest obj. |
protected static long |
DROPPED_OBJECT_WARNING_INTERVAL
Deprecated. Number of milliseconds between notifications that objects are being dropped. |
protected int |
maxObjects
Deprecated. The maximum number of objects we will hold in the queue at one time. |
protected long |
nextDroppedWarn
Deprecated. absolute time in millis when it will be ok to display a obj about dropping objects. |
protected long |
numDequeued
Deprecated. total number of objects which have been dequeued from this queue |
protected long |
numDropped
Deprecated. the number of objects we have dropped since we began working. |
protected long |
numEnqueued
Deprecated. total number of objects which have been enqueued into this queue |
protected List<Object> |
queue
Deprecated. Contains the objects we currently have queued. |
protected long |
sumOfQueueSizesDequeue
Deprecated. sum of queue sizes at dequeue time. |
protected long |
sumOfQueueSizesEnqueue
Deprecated. sum of queue sizes at enqueue time. |
Constructor Summary | |
---|---|
UnbiasedQueue()
Deprecated. Default constructor. 100 element FIFO queue which drops oldest element when full. |
|
UnbiasedQueue(int maxsize,
boolean dropOldest)
Deprecated. Full featured constructor for creating a new UnBiasedQueue. |
|
UnbiasedQueue(int maxsize,
boolean dropOldest,
List<Object> queue)
Deprecated. Full featured constructor for creating a new UnBiasedQueue. |
Method Summary | |
---|---|
void |
clear()
Deprecated. Flush the queue of all pending objects. |
void |
close()
Deprecated. Close the queue. |
double |
getAvgInQueueAtDequeue()
Deprecated. Return the average number of elements in the queue at dequeue time. |
double |
getAvgInQueueAtEnqueue()
Deprecated. Return the average number of elements in the queue at Enqueue time. |
int |
getCurrentInQueue()
Deprecated. Return the number of elements currently in the queue. |
int |
getMaxQueueSize()
Deprecated. How many objects will fit in this queue |
long |
getNumDequeued()
Deprecated. Return the total number of objects which have been dequeued from this queue during its existance. |
long |
getNumDropped()
Deprecated. Return the total number of objects which have been dropped by this queue during its existance. |
long |
getNumEnqueued()
Deprecated. Return the total number of objects which have been enqueued on to this queue during its existance. |
void |
interrupt()
Deprecated. |
boolean |
isClosed()
Deprecated. Atomically return whether or not this queue has been closed. |
Object |
peek()
Deprecated. Return the next Object from the queue without removing it. |
Object |
pop()
Deprecated. Remove and return the next Object from the queue. |
Object |
pop(long timeout)
Deprecated. Gets a Object from the queue. |
Object[] |
popMulti(int maxObjs)
Deprecated. Returns an array of objects, possibly empty, from the queue. |
boolean |
push(Object obj)
Deprecated. Attempt to push an object onto the queue. |
boolean |
push(Object obj,
long timeout)
Deprecated. Push an object onto the queue. |
boolean |
pushBack(Object obj)
Deprecated. Attempt to push an object back at the head the queue. |
boolean |
pushBack(Object obj,
long timeout)
Deprecated. Push an object back at the head of the queue. |
void |
setMaxQueueSize(int maxObjs)
Deprecated. Set how many objects this queue may store. |
static UnbiasedQueue |
synchronizedQueue(UnbiasedQueue queue)
Deprecated. Returns a synchronized (thread-safe) list backed by the specified queue. |
String |
toString()
Deprecated. A diagnostic toString implementation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_MAX_OBJECTS
protected static final boolean DROP_OLDEST_OBJECT
protected static final long DROPPED_OBJECT_WARNING_INTERVAL
protected List<Object> queue
protected int maxObjects
protected volatile boolean closeFlag
protected boolean dropOldestObject
protected long numEnqueued
protected long sumOfQueueSizesEnqueue
protected long numDequeued
protected long sumOfQueueSizesDequeue
protected long numDropped
protected long nextDroppedWarn
Constructor Detail |
---|
public UnbiasedQueue()
public UnbiasedQueue(int maxsize, boolean dropOldest)
maxsize
- Queue will not grow larger than this size. Use
Integer.MAX_VALUE
for "unbounded" queue size.dropOldest
- Controls behaviour of element insertion when the
queue is full. If true and the queue is full upon a
push
operation then the oldest element will be
dropped to be replaced with the element currently being pushed. If
false then the element will not be inserted if the queue is full.public UnbiasedQueue(int maxsize, boolean dropOldest, List<Object> queue)
maxsize
- Queue will not grow larger than this size. Use
Integer.MAX_VALUE
for "unbounded" queue size.dropOldest
- Controls behaviour of element insertion when the
queue is full. If true and the queue is full upon a
push
operation then the oldest element will be
dropped to be replaced with the element currently being pushed. If
false then the element will not be inserted if the queue is
full.queue
- the List class instance to use. This does not need to be
a synchronized list class. (and it works more effciently if it isn't).Method Detail |
---|
public static UnbiasedQueue synchronizedQueue(UnbiasedQueue queue)
queue
- the queue to be "wrapped" in a synchronized queue.public String toString()
toString
in class Object
public boolean isClosed()
public void close()
public void clear()
public boolean push(Object obj)
pop(long)
to
retrieve elements.
obj
- object to push
public boolean pushBack(Object obj)
pop(long)
to retrieve elements.
obj
- object to push
public boolean push(Object obj, long timeout) throws InterruptedException
obj
- Object to be pushed onto the queuetimeout
- Time in milliseconds to try to insert the item into a full
queue. Per Java standards, a timeout of "0" (zero) will wait indefinitly.
Negative values force no wait period at all.
InterruptedException
- if the operation is interrupted before
the timeout interval is completed.public boolean pushBack(Object obj, long timeout) throws InterruptedException
Object.wait(long)
. pushBack(Object,long)
should only
be used in conjunction with push(Object,long)
and
pop(long)
obj
- Object to be pushed onto the queuetimeout
- Time in milliseconds to try to insert the item into a full
queue. Per Java standards, a timeout of "0" (zero) will wait indefinitly.
Negative values force no wait period at all.
InterruptedException
- if the operation is interrupted before
the timeout interval is completed.public Object peek()
public Object pop()
public Object pop(long timeout) throws InterruptedException
timeout
- Amount of time to wait in milliseconds for an object to
be available. Per Java convention, a timeout of zero (0) means wait an
infinite amount of time. Negative values mean do not wait at all.
InterruptedException
- if the operation is interrupted before
the timeout interval is completed.public Object[] popMulti(int maxObjs)
maxObjs
- the maximum number of items to return.
public int getMaxQueueSize()
public void setMaxQueueSize(int maxObjs)
maxObjs
- The number of objects which the queue must be able to
store.public int getCurrentInQueue()
push(Object)
and pop(long)
methods to regulate how you
use the queue.
public long getNumEnqueued()
public double getAvgInQueueAtEnqueue()
public long getNumDequeued()
public double getAvgInQueueAtDequeue()
public long getNumDropped()
public void interrupt()
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |