sunlabs.brazil.template

Class QueueTemplate.Queue

public static class QueueTemplate.Queue extends Object

Create an object queue. "Getters" wait 'till something appears in the queue.
Field Summary
static intmax
Constructor Summary
Queue()
Create a new Q of a maximum possible size
Method Summary
voidclear()
Clear the queue.
longcount()
Return the total number of items Q'd.
Objectget(int timeout)
Return the next item on the queue, waiting for up to "timeout" seconds or for an interrupt.
longgetCreated()
Return creation time (ms since epoch).
longgetExpires()
Get the expiration period of the Queue (in ms).
booleanisClosed()
Get the closed state.
voidkick()
Send a notify: for debugging
longlastIn()
Return the last time a Q insertion was attempted.
longlastOut()
Return the last time a Q removal was attempted.
booleanput(Object item)
Put an item on the queue if it's open and not full.
booleanput(Object item, boolean force)
Put an item on the queue if it's not full.
booleansetClosed(boolean closed)
Set the closed state.
voidsetExpires(long expires)
Set the expiration period of the Queue (in ms).
intsize()
How many items are queue'd.
StringtoString()

Field Detail

max

public static int max

Constructor Detail

Queue

public Queue()
Create a new Q of a maximum possible size

Method Detail

clear

public void clear()
Clear the queue.

count

public long count()
Return the total number of items Q'd.

Returns: The # of Q'd items.

get

public Object get(int timeout)
Return the next item on the queue, waiting for up to "timeout" seconds or for an interrupt.

Returns: the top of the Q, or null.

getCreated

public long getCreated()
Return creation time (ms since epoch).

getExpires

public long getExpires()
Get the expiration period of the Queue (in ms). The notion of when a queue expires is application dependent. Applications can look at count() lastIn(), lastOut(). and created() to determine when the Q is expired for them.

isClosed

public boolean isClosed()
Get the closed state.

kick

public void kick()
Send a notify: for debugging

lastIn

public long lastIn()
Return the last time a Q insertion was attempted.

Returns: -1 if no attempts were made.

lastOut

public long lastOut()
Return the last time a Q removal was attempted.

Returns: -1 if no attempts were made.

put

public boolean put(Object item)
Put an item on the queue if it's open and not full.

put

public boolean put(Object item, boolean force)
Put an item on the queue if it's not full. If "force" is true, override the "closed" flag.

setClosed

public boolean setClosed(boolean closed)
Set the closed state.

setExpires

public void setExpires(long expires)
Set the expiration period of the Queue (in ms).

size

public int size()
How many items are queue'd.

toString

public String toString()