public class IndexedXQueue extends java.lang.Object implements XQueue
CELL_EMPTY, CELL_OCCUPIED, CELL_OUTBOUND, CELL_RESERVED, CELL_TAKEN, EXTERNAL_XA, KEEP_RUNNING, PAUSE, STANDBY, XQ_ERROR
Constructor and Description |
---|
IndexedXQueue(java.lang.String name,
int capacity)
initialzes a queue with capacity of cells
|
Modifier and Type | Method and Description |
---|---|
int |
add(java.lang.Object obj,
int id)
adds a new object to the reserved cell at id so that it is ready to be
taken
|
int |
add(java.lang.Object obj,
int id,
XQCallbackWrapper cbw)
adds a new object and a callback wrapper to the reserved cell at id
so that it is ready to be taken
|
boolean |
available()
test if any cell is occupied or any object is ready to be taken
|
java.lang.Object |
browse(int id)
returns the object in the id-th cell or null if id out of bound
|
Browser |
browser()
returns an instance of Browser for ids of occupied cells
|
int |
cancel(int id)
cancels the reservation on the id-th cell and returns watermark
|
void |
clear()
clear all cells and reset all marks
|
int |
collect(long milliSec)
collects the next collectible cell so that it is ready to be reserved
|
int |
collect(long milliSec,
int id)
collects the id-th cell so that it is ready to be reserved.
|
int |
collect(long milliSec,
int begin,
int len)
collects the first collectible cell out of len cells starting from begin
|
int |
collectible()
returns the number of collectible objects in the queue
|
int |
depth()
returns the number of new objects in the queue
|
protected void |
finalize() |
int |
getCapacity()
returns the capacity of the queue
|
int |
getCellStatus(int id)
returns the status of the id-th cell if it is not out of bound, or -1
otherwise
|
long |
getCount()
returns the number of objects taken out of the queue since the
reset at its timestamp
|
int |
getGlobalMask()
returns the global mask of the queue
|
long |
getMTime()
returns the timestamp of the reset on the queue
|
java.lang.String |
getName()
returns the name of the queue
|
int |
getNextCell(long milliSec)
returns the id of the next occupied cell or -1 if there is none
|
int |
getNextCell(long milliSec,
int id)
checks the cell at the index of id for its occupancy and returns the id
if it is occupied or -1 if it is not.
|
int |
getNextCell(long milliSec,
int begin,
int len)
gets the first occupied cell out of len cells starting from begin
|
boolean |
isCollectible()
returns true if the queue supports collectible() and collect()
|
boolean |
isFull()
returns true if the queue is full or false otherwise
|
int |
locate(int[] ids,
int begin,
int len)
locates all unreserved empty cells among the given ids in the list
starting from the index of begin thru the index of begin+len-1.
|
int |
putback(int id)
puts the in-use object back to the cell with the id and makes the cell
occupied again so that the object is ready to be taken.
|
int |
remove(int id)
removes the object from the id-th cell and makes the cell empty so that
it can be occupied again.
|
int |
reserve(long milliSec)
reserves the next empty cell so that it is ready to be occupied
|
int |
reserve(long milliSec,
int id)
reserves the id-th cell so that it is ready to be occupied.
|
int |
reserve(long milliSec,
int begin,
int len)
reserves the first empty cell out of len cells starting from begin
|
long |
reset()
resets the counter to 0, updates the timestamp and returns the total
number of objects taken out of the queue since the previous reset
|
void |
setGlobalMask(int mask)
sets the global mask of the queue
|
int |
size()
returns the number of objects in the queue, new and taken
|
java.lang.Object |
takeback(int id)
takes back the new object in the id-th cell and makes the cell empty
again while keeping the order on other occupied cells
|
public IndexedXQueue(java.lang.String name, int capacity)
public java.lang.String getName()
XQueue
public int size()
public int depth()
public int collectible()
collectible
in interface XQueue
public long getCount()
XQueue
public long getMTime()
XQueue
public long reset()
XQueue
public int getCapacity()
XQueue
getCapacity
in interface XQueue
public int getGlobalMask()
XQueue
getGlobalMask
in interface XQueue
public void setGlobalMask(int mask)
XQueue
setGlobalMask
in interface XQueue
public boolean available()
public boolean isFull()
XQueue
public boolean isCollectible()
XQueue
isCollectible
in interface XQueue
public int collect(long milliSec, int id)
public int collect(long milliSec, int begin, int len)
public int collect(long milliSec)
public int reserve(long milliSec, int id)
public int reserve(long milliSec, int begin, int len)
public int reserve(long milliSec)
public int cancel(int id)
public int add(java.lang.Object obj, int id)
public int add(java.lang.Object obj, int id, XQCallbackWrapper cbw)
public java.lang.Object takeback(int id)
public int getNextCell(long milliSec)
getNextCell
in interface XQueue
public int getNextCell(long milliSec, int id)
getNextCell
in interface XQueue
public int getNextCell(long milliSec, int begin, int len)
getNextCell
in interface XQueue
public java.lang.Object browse(int id)
public int putback(int id)
public int remove(int id)
public int getCellStatus(int id)
getCellStatus
in interface XQueue
public int locate(int[] ids, int begin, int len)
public Browser browser()
public void clear()
XQueue
protected void finalize()
finalize
in class java.lang.Object