|
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.UnbiasedQueue.SynchronizedQueue
protected static class UnbiasedQueue.SynchronizedQueue
An inner class for wrapping arbitrary queues with synchronization.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.jxta.impl.util.UnbiasedQueue |
---|
UnbiasedQueue.SynchronizedQueue |
Field Summary | |
---|---|
(package private) UnbiasedQueue |
innerqueue
|
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 | |
---|---|
UnbiasedQueue.SynchronizedQueue(UnbiasedQueue queue)
Constructs a SynchronizedQueue from an UnbiasedQueue instance. |
Method Summary | |
---|---|
void |
clear()
Flush the queue of all pending objects. |
void |
close()
Close the queue. |
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. |
int |
getMaxQueueSize()
How many objects will fit in this queue |
long |
getNumDequeued()
Return the total number of objects which have been dequeued from this queue during its existance. |
long |
getNumDropped()
Return the total number of objects which have been dropped by this queue during its existance. |
long |
getNumEnqueued()
Return the total number of objects which have been enqueued on to this queue during its existance. |
boolean |
isClosed()
Atomically return whether or not this queue has been closed. |
Object |
peek()
Return the next Object from the queue without removing it. |
Object |
pop()
Remove and return the next Object from the queue. |
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. |
boolean |
push(Object obj,
long timeout)
Push an object onto the queue. |
boolean |
pushBack(Object obj)
Attempt to push an object back at the head the queue. |
boolean |
pushBack(Object obj,
long timeout)
Push an object back at the head of the queue. |
void |
setMaxQueueSize(int maxObjs)
Set how many objects this queue may store. |
Methods inherited from class net.jxta.impl.util.UnbiasedQueue |
---|
interrupt, synchronizedQueue, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
UnbiasedQueue innerqueue
Constructor Detail |
---|
public UnbiasedQueue.SynchronizedQueue(UnbiasedQueue queue)
Method Detail |
---|
public boolean isClosed()
isClosed
in class UnbiasedQueue
public void close()
close
in class UnbiasedQueue
public void clear()
clear
in class UnbiasedQueue
public boolean push(Object obj)
UnbiasedQueue.pop(long)
to
retrieve elements.
push
in class UnbiasedQueue
obj
- object to push
public boolean pushBack(Object obj)
UnbiasedQueue.pop(long)
to retrieve elements.
pushBack
in class UnbiasedQueue
obj
- object to push
public boolean push(Object obj, long timeout) throws InterruptedException
push
in class UnbiasedQueue
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)
. UnbiasedQueue.pushBack(Object,long)
should only
be used in conjunction with UnbiasedQueue.push(Object,long)
and
UnbiasedQueue.pop(long)
pushBack
in class UnbiasedQueue
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()
peek
in class UnbiasedQueue
public Object pop()
pop
in class UnbiasedQueue
public Object pop(long timeout) throws InterruptedException
pop
in class UnbiasedQueue
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)
popMulti
in class UnbiasedQueue
maxObjs
- the maximum number of items to return.
public int getMaxQueueSize()
getMaxQueueSize
in class UnbiasedQueue
public void setMaxQueueSize(int maxObjs)
setMaxQueueSize
in class UnbiasedQueue
maxObjs
- The number of objects which the queue must be able to
store.public int getCurrentInQueue()
UnbiasedQueue
UnbiasedQueue.push(Object)
and UnbiasedQueue.pop(long)
methods to regulate how you
use the queue.
getCurrentInQueue
in class UnbiasedQueue
public long getNumEnqueued()
getNumEnqueued
in class UnbiasedQueue
public double getAvgInQueueAtEnqueue()
getAvgInQueueAtEnqueue
in class UnbiasedQueue
public long getNumDequeued()
getNumDequeued
in class UnbiasedQueue
public double getAvgInQueueAtDequeue()
getAvgInQueueAtDequeue
in class UnbiasedQueue
public long getNumDropped()
getNumDropped
in class UnbiasedQueue
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |