java.lang.Object
net.i2p.router.transport.ntcp.Reader
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 Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionvoidDynamically adjust thread count to match the target.voidRemoves a closed connection from the queues.intNumber of threads currently processing (not parked).static intReader thread count.doubleReader pool utilization as a ratio (0.0-1.0).static voidsetThreadCount(int count) Reader thread count, bounded by MIN_THREADS-MAX_THREADS.voidstartReading(int numReaders) Starts the given number of reader threads.voidStop all reader threads.voidwantsRead(NTCPConnection con) Registers a connection to be read.
Constructor Details
Reader
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
Registers a connection to be read. High-frequency per-buffer path.- Parameters:
con- the connection with data waiting to be read
connectionClosed
Removes a closed connection from the queues.- Parameters:
con- the connection to drop from the pending and read-after-live queues