java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.client.streaming.impl.MessageOutputStream.Flusher
- All Implemented Interfaces:
Runnable
- Enclosing class:
MessageOutputStream
Passive flush timer to flush buffered data after inactivity delay. Ensures data does not stay buffered indefinitely.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanTrue while the stream waits in the event queue.Fields 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
ConstructorsMethod Summary
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
_enqueued
private volatile boolean _enqueuedTrue while the stream waits in the event queue.
Constructor Details
Flusher
Flusher with the given timer.- Parameters:
timer- timer to schedule flush events
Method Details
enqueue
public void enqueue()Enqueues or reschedules the flush event after the passive flush delay. Avoids scheduling duplicate flush events.timeReached
public void timeReached()Called when flush timer expires. Attempts passive flush if no recent writes detected or if no write in progress.- Specified by:
timeReachedin classSimpleTimer2.TimedEvent
doFlush
private void doFlush()Performs the actual flush of buffered data, if any. If data is available and the passive flush delay has elapsed, writes data to the data receiver and resets the buffer.Handles null WriteStatus gracefully to avoid NullPointerException.