java.lang.Object
net.i2p.router.transport.ntcp.Reader

public class Readerextends Object
Pool of running threads which will process any read bytes on any of the NTCPConnections, including decryption of the data read, connection handshaking, parsing bytes into I2NP messages, etc. Provides efficient buffer management and connection lifecycle coordination. Supports dynamic thread count adjustment via adjustThreads().
  • Constructor Details

    • Reader

      public Reader(RouterContext ctx)
      Reader thread pool for the given context.
      Parameters:
      ctx - the router context supplying the log and the clock
  • Method Details

    • getThreadCount

      public static int getThreadCount()
      Reader thread count.
      Returns:
      the target number of reader threads, 2 to 16
    • getActiveCount

      public int getActiveCount()
      Number of threads currently processing (not parked).
      Returns:
      the count of runners that are inside the read loop
    • getUtilization

      public double getUtilization()
      Reader pool utilization as a ratio (0.0-1.0). NaN if no runners are active (pool not started).
      Returns:
      the utilization as a ratio from 0.0 to 1.0, or NaN if no runners are active
    • setThreadCount

      public static void setThreadCount(int count)
      Reader thread count, bounded by MIN_THREADS-MAX_THREADS.
      Parameters:
      count - the requested target, clamped into the range 2 to 16
    • startReading

      public void startReading(int numReaders)
      Starts the given number of reader threads.
      Parameters:
      numReaders - how many runners to add to those already started
    • adjustThreads

      public void adjustThreads()
      Dynamically adjust thread count to match the target.
    • stopReading

      public void stopReading()
      Stop all reader threads.
    • wantsRead

      public void wantsRead(NTCPConnection con)
      Registers a connection to be read. High-frequency per-buffer path.
      Parameters:
      con - the connection with data waiting to be read
    • connectionClosed

      public void connectionClosed(NTCPConnection con)
      Removes a closed connection from the queues.
      Parameters:
      con - the connection to drop from the pending and read-after-live queues