java.lang.Object
net.i2p.client.streaming.impl.RetransmissionTimer
Per-destination timer for scheduling packet retransmissions. Uses dedicated SimpleTimer2 shards (not the router-global one) to isolate streaming timer events from contention with other subsystems.
The events are spread over SHARDS independent timers, so a connection whose timer queue is saturated by retransmission/ack events cannot hold up an unrelated connection's handshake or keepalive. Each shard keeps SimpleTimer2's two worker threads, so a single long-running event blocks only its own workers.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicIntegerRound-robin index choosing the next shardprivate final SimpleTimer2[]The timers, split into shards to spread the lockingprivate static final intNumber of independent timer shards.Constructor Summary
ConstructorsConstructorDescriptionRetransmissionTimer(I2PAppContext ctx, String name) New timer with dedicated SimpleTimer2 shards.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidaddEvent(SimpleTimer2.TimedEvent event, long timeoutMs) Schedule an event via one of the dedicated timers.A SimpleTimer2 instance for a new consumer.voidstop()Stop all dedicated timers.
Field Details
SHARDS
private static final int SHARDSNumber of independent timer shards. Connections are assigned round-robin, halving the chance that concurrent connections share a timer queue.- See Also:
_shards
The timers, split into shards to spread the locking_counter
Round-robin index choosing the next shard
Constructor Details
RetransmissionTimer
RetransmissionTimer(I2PAppContext ctx, String name) New timer with dedicated SimpleTimer2 shards.- Parameters:
ctx- the application contextname- used for the timer thread names
Method Details
addEvent
Schedule an event via one of the dedicated timers.- Parameters:
event- the SimpleTimer2 event to fire once timeoutMs has elapsedtimeoutMs- delay in ms
stop
public void stop()Stop all dedicated timers.