java.lang.Object
net.i2p.router.client.ClientWriterRunner
- All Implemented Interfaces:
Runnable
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router context the writer runs in.private final BlockingQueue<I2CPMessage> Messages waiting to go out to the client.private final ClientConnectionRunnerThe connection these messages belong to.private static intMax messages queued per client before blocking.Constructor Summary
ConstructorsConstructorDescriptionClientWriterRunner(RouterContext ctx, ClientConnectionRunner runner) Creates a new client writer runner.Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(I2CPMessage msg) Add this message to the writer's queuestatic intThe current size of the message queue.voidrun()static voidsetQueueSize(int val) Update the message queue size, clamped to the supported range.voidNo more messages - don't even try to send what we have.
Field Details
_messagesToWrite
Messages waiting to go out to the client._runner
The connection these messages belong to._context
The router context the writer runs in.queueSize
private static volatile int queueSizeMax messages queued per client before blocking.
Constructor Details
ClientWriterRunner
Creates a new client writer runner.- Parameters:
ctx- the router contextrunner- the client connection runner
Method Details
getQueueSize
public static int getQueueSize()The current size of the message queue.- Returns:
- the queue size
setQueueSize
public static void setQueueSize(int val) Update the message queue size, clamped to the supported range.- Parameters:
val- the new queue size
addMessage
Add this message to the writer's queueNonblocking, throws exception if queue is full.
- Parameters:
msg- the message to add- Throws:
I2CPMessageException- if the queue is full
stopWriting
public void stopWriting()No more messages - don't even try to send what we have.run