java.lang.Object
net.i2p.router.Tuner.ThreadCpuTable.Slots
Enclosing class:
Tuner.ThreadCpuTable

private static final class Tuner.ThreadCpuTable.Slotsextends Object
One generation of the table: parallel arrays probed by the same index, keyed by thread id so no id is ever boxed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) long[]
    CPU ns at the previous sample, Tuner.ThreadCpuTable.NO_CPU when none.
    (package private) long[]
    Thread id per slot, Tuner.ThreadCpuTable.EMPTY when free.
    (package private) int
    Capacity minus one, so a probe wraps with a mask instead of a modulo.
    (package private) int
    Entries in use.
    (package private) byte[]
  • Constructor Summary

    Constructors
    Constructor
    Description
    Slots(int capacity)
    Creates an open-addressed id table of the given capacity.
  • Method Summary

    Private Methods
    Modifier and Type
    Method
    Description
    (package private) void
    Empties the table.
    (package private) int
    index(long id)
    Finds the slot holding the id in the open addressed table.
    (package private) int
    insert(long id, int stageVal, long cpuNs)
    Records a build id with its stage and CPU time.
    private void
    Doubles the table and reinserts every record.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 record
      stageVal - the stage index
      cpuNs - 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.