public class RandomGrabArray extends java.lang.Object implements RemoveRandom, RequestSelectionTreeNode
RemoveRandom.RemoveRandomReturn
Modifier and Type | Field and Description |
---|---|
protected ClientRequestSelector |
root |
Constructor and Description |
---|
RandomGrabArray(RemoveRandomParent parent,
ClientRequestSelector root) |
Modifier and Type | Method and Description |
---|---|
void |
add(RandomGrabArrayItem req,
ClientContext context) |
void |
clearWakeupTime(ClientContext context)
When a request becomes fetchable, set all the wakeup times above it to 0.
|
boolean |
contains(RandomGrabArrayItem item) |
RandomGrabArrayItem |
get(int idx) |
RequestSelectionTreeNode |
getParentGrabArray()
Return the parent RequestSelectionTreeNode or null if it's not in the tree or is the root (e.g.
|
long |
getWakeupTime(ClientContext context,
long now)
Unless this is a RandomGrabArrayItem, this will return the wakeup time for the subtree
rooted at this node.
|
int |
hashCode() |
boolean |
isEmpty() |
void |
moveElementsTo(RandomGrabArray existingGrabber,
boolean canCommit) |
boolean |
reduceWakeupTime(long wakeupTime,
ClientContext context)
If the current cooldown time is larger than the parameter, reduce it and recurse up the
tree.
|
void |
remove(RandomGrabArrayItem it,
ClientContext context) |
RemoveRandom.RemoveRandomReturn |
removeRandom(RandomGrabArrayItemExclusionList excluding,
ClientContext context,
long now)
Return a random RandomGrabArrayItem, or a time at which there will be one, or null
if the RGA is empty and should be removed by the parent.
|
void |
setParent(RemoveRandomParent newParent) |
int |
size() |
protected ClientRequestSelector root
public RandomGrabArray(RemoveRandomParent parent, ClientRequestSelector root)
public int hashCode()
hashCode
in class java.lang.Object
public void add(RandomGrabArrayItem req, ClientContext context)
public RemoveRandom.RemoveRandomReturn removeRandom(RandomGrabArrayItemExclusionList excluding, ClientContext context, long now)
RemoveRandom
removeRandom
in interface RemoveRandom
public void remove(RandomGrabArrayItem it, ClientContext context)
public boolean isEmpty()
public boolean contains(RandomGrabArrayItem item)
public int size()
public RandomGrabArrayItem get(int idx)
public void moveElementsTo(RandomGrabArray existingGrabber, boolean canCommit)
public void setParent(RemoveRandomParent newParent)
setParent
in interface RemoveRandom
public RequestSelectionTreeNode getParentGrabArray()
RequestSelectionTreeNode
getParentGrabArray
in interface RequestSelectionTreeNode
public long getWakeupTime(ClientContext context, long now)
RequestSelectionTreeNode
getWakeupTime
in interface RequestSelectionTreeNode
public boolean reduceWakeupTime(long wakeupTime, ClientContext context)
RequestSelectionTreeNode
reduceWakeupTime
in interface RequestSelectionTreeNode
public void clearWakeupTime(ClientContext context)
RequestSelectionTreeNode
clearWakeupTime
in interface RequestSelectionTreeNode