|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.core.messenger.PacketQueue
This class implements a queue of packets.
Packets are added at the end of the queue, and removed from the front. The queue can have a size limit set - when reached, all calls to add a new packet will block.
Packet
Constructor Summary | |
PacketQueue()
Creates a new empty queue, of unlimited size |
|
PacketQueue(int limit)
Creates a new empty queue, of limited size. |
Method Summary | |
void |
add(org.exolab.core.messenger.Packet packet)
Add a new packet to the end of the queue. |
void |
close()
Close the queue. |
boolean |
isClosed()
Returns true if the queue is closed |
boolean |
isEmpty()
Returns true if this queue is empty |
org.exolab.core.messenger.Packet |
peek()
Return the packet at the front of the queue, without removing it. |
org.exolab.core.messenger.Packet |
remove()
Remove a packet from the top of the queue. |
boolean |
waitForPacket(long timeout)
Wait at most timeout milliseconds until a packet
is available |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PacketQueue()
public PacketQueue(int limit)
limit
- the maximum number of packets that the queue can contain
at any one time.Method Detail |
public void add(org.exolab.core.messenger.Packet packet)
packet
- the packet to add
java.lang.IllegalArgumentException
- if packet is nullpublic org.exolab.core.messenger.Packet remove()
null
, if the queue
has been closedpublic org.exolab.core.messenger.Packet peek()
null
if no packet is currently queuedpublic boolean waitForPacket(long timeout)
timeout
milliseconds until a packet
is available
timeout
- the maximum time to wait (in milliseconds) for
a packet to become available. A timeout of zero never expires and the
call blocks indefinitely, or until the queue is closed
true
if a packet becomes available in the
specified timepublic boolean isEmpty()
true
if this queue is empty
true
if this queue is emptypublic void close()
public boolean isClosed()
true
if the queue is closed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |