java.lang.Object
net.i2p.router.Tuner.ThreadCpuTable.Slots
- Enclosing class:
Tuner.ThreadCpuTable
One generation of the table: parallel arrays probed by the same index, keyed by thread id so no id is ever boxed.
Field Summary
FieldsModifier and TypeFieldDescription(package private) long[]CPU ns at the previous sample,Tuner.ThreadCpuTable.NO_CPUwhen none.(package private) long[]Thread id per slot,Tuner.ThreadCpuTable.EMPTYwhen free.(package private) intCapacity minus one, so a probe wraps with a mask instead of a modulo.(package private) intEntries in use.(package private) byte[]Tuner.CPU_STAGESindex,Tuner.ThreadCpuTable.UNRESOLVEDwhen unknown.Constructor Summary
ConstructorsMethod Summary
Private MethodsModifier and TypeMethodDescription(package private) voidclear()Empties the table.(package private) intindex(long id) Finds the slot holding the id in the open addressed table.(package private) intinsert(long id, int stageVal, long cpuNs) Records a build id with its stage and CPU time.private voidrehash()Doubles the table and reinserts every record.
Field Details
ids
long[] idsThread id per slot,Tuner.ThreadCpuTable.EMPTYwhen free.cpu
long[] cpuCPU ns at the previous sample,Tuner.ThreadCpuTable.NO_CPUwhen none.stage
byte[] stageTuner.CPU_STAGESindex,Tuner.ThreadCpuTable.UNRESOLVEDwhen unknown.mask
int maskCapacity minus one, so a probe wraps with a mask instead of a modulo.size
int sizeEntries in use.
Constructor Details
Slots
Slots(int capacity) Creates an open-addressed id table of the given capacity.- Parameters:
capacity- minimum number of ids it must hold
Method Details
clear
void clear()Empties the table.index
int index(long id) Finds the slot holding the id in the open addressed table.- Parameters:
id- the id to look up- Returns:
- the slot holding it, -1 when it is absent
insert
int insert(long id, int stageVal, long cpuNs) Records a build id with its stage and CPU time.- Parameters:
id- the build id to recordstageVal- the stage indexcpuNs- the CPU time used, in ns- Returns:
- the slot the record was placed in
rehash
private void rehash()Doubles the table and reinserts every record.