|
Project JXTA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.jxta.impl.util.UnbiasedQueue
net.jxta.impl.util.ProducerBiasedQueue
public class ProducerBiasedQueue
A queue who's implementation is biased towards effciency in adding elements to the queue.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.jxta.impl.util.UnbiasedQueue |
|---|
UnbiasedQueue.SynchronizedQueue |
| Field Summary |
|---|
| Fields inherited from class net.jxta.impl.util.UnbiasedQueue |
|---|
closeFlag, DEFAULT_MAX_OBJECTS, DROP_OLDEST_OBJECT, dropOldestObject, DROPPED_OBJECT_WARNING_INTERVAL, maxObjects, nextDroppedWarn, numDequeued, numDropped, numEnqueued, queue, sumOfQueueSizesDequeue, sumOfQueueSizesEnqueue |
| Constructor Summary | |
|---|---|
ProducerBiasedQueue()
Default constructor. 100 element FIFO queue which drops oldest element when full. |
|
ProducerBiasedQueue(int size,
boolean dropOldest)
Full featured constructor for creating a new ConsumerBiasedQueue. |
|
| Method Summary | |
|---|---|
void |
clear()
Flush the queue of all pending objects. |
double |
getAvgInQueueAtDequeue()
Return the average number of elements in the queue at dequeue time. |
double |
getAvgInQueueAtEnqueue()
Return the average number of elements in the queue at Enqueue time. |
int |
getCurrentInQueue()
Return the number of elements currently in the queue. |
Object |
pop()
Return next obj in the queue if there is one. |
Object |
pop(long timeout)
Gets a Object from the queue. |
Object[] |
popMulti(int maxObjs)
Returns an array of objects, possibly empty, from the queue. |
boolean |
push(Object obj)
Attempt to push an object onto the queue. |
void |
setMaxQueueSize(int maxObjs)
Set how many objects this queue may store. |
| Methods inherited from class net.jxta.impl.util.UnbiasedQueue |
|---|
close, getMaxQueueSize, getNumDequeued, getNumDropped, getNumEnqueued, interrupt, isClosed, peek, push, pushBack, pushBack, synchronizedQueue, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ProducerBiasedQueue()
public ProducerBiasedQueue(int size,
boolean dropOldest)
size - Queue will be 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 then newest item will be dropped.| Method Detail |
|---|
public void clear()
clear in class UnbiasedQueuepublic boolean push(Object obj)
UnbiasedQueueUnbiasedQueue.pop(long) to
retrieve elements.
push in class UnbiasedQueueobj - object to push
public Object pop()
pop in class UnbiasedQueue
public Object pop(long timeout)
throws InterruptedException
pop in class UnbiasedQueuetimeout - 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)
popMulti in class UnbiasedQueuemaxObjs - the maximum number of items to return.
public void setMaxQueueSize(int maxObjs)
setMaxQueueSize in class UnbiasedQueuemaxObjs - The number of objects which the queue must be able to
store.public int getCurrentInQueue()
getCurrentInQueue in class UnbiasedQueuepublic double getAvgInQueueAtEnqueue()
getAvgInQueueAtEnqueue in class UnbiasedQueuepublic double getAvgInQueueAtDequeue()
getAvgInQueueAtDequeue in class UnbiasedQueue
|
JXTA J2SE | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||