java.lang.Object
net.i2p.internal.I2CPMessageQueue
net.i2p.router.client.I2CPMessageQueueImpl
- All Implemented Interfaces:
Closeable, AutoCloseable
Contains the methods to talk to a router or client via I2CP, when both are in the same JVM. This interface contains methods to access two queues, one for transmission and one for receiving. The methods are identical to those in java.util.concurrent.BlockingQueue.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BlockingQueue<I2CPMessage> Queue messages from the client arrive on.private final BlockingQueue<I2CPMessage> Queue messages to the client are written to.Constructor Summary
ConstructorsConstructorDescriptionWrap a pair of queues as an I2CP message queue.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanoffer(I2CPMessage msg) Send a message, nonblocking.booleanoffer(I2CPMessage msg, long timeout) Send a message, blocking.intpending()Messages waiting to be read by the client.poll()Receive a message, non-blocking.voidput(I2CPMessage msg) Send a message, blocking until space is available.intSlots free for messages from the client.take()Receive a message, blocking until one is available.Methods inherited from class I2CPMessageQueue
close
Field Details
_in
Queue messages from the client arrive on._out
Queue messages to the client are written to.
Constructor Details
I2CPMessageQueueImpl
Wrap a pair of queues as an I2CP message queue.- Parameters:
in- the queue messages from the client arrive onout- the queue messages to the client are written to
Method Details
offer
Send a message, nonblocking.- Specified by:
offerin classI2CPMessageQueue- Parameters:
msg- the message to enqueue for the router to read- Returns:
- success (false if no space available)
offer
Send a message, blocking.- Specified by:
offerin classI2CPMessageQueue- Parameters:
msg- the message to enqueue for the router to readtimeout- how long to wait for space (ms)- Returns:
- success (false if no space available or if timed out)
- Throws:
InterruptedException- if the calling thread is interrupted while waiting for space to become available
poll
Receive a message, non-blocking.- Specified by:
pollin classI2CPMessageQueue- Returns:
- message or null if none available
pending
public int pending()Messages waiting to be read by the client.- Specified by:
pendingin classI2CPMessageQueue- Returns:
- messages waiting to be received
remainingCapacity
public int remainingCapacity()Slots free for messages from the client.- Specified by:
remainingCapacityin classI2CPMessageQueue- Returns:
- how many more messages will be accepted;
Integer.MAX_VALUEwhen unbounded
put
Send a message, blocking until space is available.- Specified by:
putin classI2CPMessageQueue- Parameters:
msg- the message to enqueue for the router to read- Throws:
InterruptedException- if the calling thread is interrupted while waiting for space to become available
take
Receive a message, blocking until one is available.- Specified by:
takein classI2CPMessageQueue- Returns:
- the next message removed from the inbound side of the queue
- Throws:
InterruptedException- if the calling thread is interrupted while waiting for a message to arrive