java.lang.Object
net.i2p.client.impl.ClientWriterRunner
- All Implemented Interfaces:
Runnable
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AtomicLongCounts the writer threads created.private final BlockingQueue<I2CPMessage> Messages waiting to reach the router.private final OutputStreamWhere messages are written to the router.private final I2PSessionImplThe session whose messages are written.private static final intMost messages queued before writes start blocking.private static final longLongest a send waits for the queue to drain, in ms.Constructor Summary
ConstructorsConstructorDescriptionClientWriterRunner(OutputStream out, I2PSessionImpl session) Create the writer for a session, buffering I2CP messages queued for output to that session.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidaddMessage(I2CPMessage msg) Add this message to the writer's queue.voidrun()voidStarts the daemon thread that drains the queue and writes to the session's output stream.voidNo more messages - don't even try to send what we have.
Field Details
_out
Where messages are written to the router._session
The session whose messages are written._messagesToWrite
Messages waiting to reach the router.__Id
Counts the writer threads created.MAX_QUEUE_SIZE
private static final int MAX_QUEUE_SIZEMost messages queued before writes start blocking.MAX_SEND_WAIT
private static final long MAX_SEND_WAITLongest a send waits for the queue to drain, in ms.
Constructor Details
ClientWriterRunner
Create the writer for a session, buffering I2CP messages queued for output to that session.As of 0.9.11 does not start the thread, caller must call
startWriting().- Parameters:
out- stream the I2CP messages are written to, buffered internallysession- session to poll for closure and to report write failures to
Method Details
startWriting
public void startWriting()Starts the daemon thread that drains the queue and writes to the session's output stream.addMessage
Add this message to the writer's queue. Blocking if queue is full.- Parameters:
msg- the message to queue for writing to the session's output stream- Throws:
I2PSessionException- if we wait too long or are interrupted
stopWriting
public void stopWriting()No more messages - don't even try to send what we have.run