- All Implemented Interfaces:
Runnable
- Enclosing class:
Connection
_resendEventPool for reuse.Field Summary
FieldsFields inherited from class SimpleTimer2.TimedEvent
_state, DEFAULT_FUZZModifier and TypeFieldDescriptionprotected SimpleTimer2.TimedEventStateState of the current event.protected static final intDefault fuzz threshold in milliseconds.Constructor Summary
ConstructorsConstructorDescriptionResendPacketEvent(PacketLocal packet) Bind the event to a packet and the router's shared timer.Method Summary
Modifier and TypeMethodDescription(package private) voidFire an immediate retransmit instead of waiting out the current RTO.private booleanRetransmit the packet if we need to.voidRetransmit the packet when the timer fires, then return this event to the pool for reuse.Methods inherited from class SimpleTimer2.TimedEvent
cancel, forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringModifier and TypeMethodDescriptionbooleancancel()Cancel the timed event.voidforceReschedule(long timeoutMs) Always use the new time - ignores fuzz.voidreschedule(long timeoutMs) Use the earliest of the new time and the old time May be called from within timeReached(), but schedule() is better there.voidreschedule(long timeoutMs, boolean useEarliestTime) May be called from within timeReached(), but schedule() is better there.voidrun()voidschedule(long timeoutMs) Schedule this event.voidsetFuzz(int fuzz) Reschedule threshold in ms.voidsetPool(SimpleTimer2 pool) Timer pool for this event.toString()Timer summary for log messages.
Field Details
_packet
The packet to retransmit.
Constructor Details
ResendPacketEvent
Bind the event to a packet and the router's shared timer.- Parameters:
packet- the packet to retransmit when the event fires
Method Details
timeReached
public void timeReached()Retransmit the packet when the timer fires, then return this event to the pool for reuse.- Specified by:
timeReachedin classSimpleTimer2.TimedEvent
fastRetransmit
void fastRetransmit()Fire an immediate retransmit instead of waiting out the current RTO.retransmit
private boolean retransmit()Retransmit the packet if we need to.ackImmediately() above calls directly in here, so we have to use forceReschedule() instead of schedule() below, to prevent duplicates in the timer queue.
Don't synchronize this, deadlock with ackPackets->ackReceived->SimpleTimer2.cancel
Historical note on the lock warning: SimpleTimer2 now invokes
TimedEvent.timeReached()/run() outside any SimpleTimer2 monitor (only checkAndPrepareRun/updateStateAfterRun are brief synchronized scopes), so the called-from-across-the-wire locks taken in ackPackets() and here cannot form a monitor cycle with this thread. A short synchronized (_outboundPacketsLock) in the reset path below is therefore deadlock-safe; ackPackets() holds the same lock only for mapping + ack bookkeeping, never while calling SimpleTimer2.- Returns:
- true if the packet was sent, false if it was not