net.i2p.router.client

## Class I2CPMessageQueueImpl

- java.lang.Object
- - net.i2p.internal.I2CPMessageQueue
  - - net.i2p.router.client.I2CPMessageQueueImpl

- All Implemented Interfaces:
    Closeable, AutoCloseable

      class I2CPMessageQueueImpl
      extends I2CPMessageQueue

  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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `I2CPMessageQueueImpl(BlockingQueue<I2CPMessage> in, BlockingQueue<I2CPMessage> out)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `offer(I2CPMessage msg)` Send a message, nonblocking
    `boolean` | `offer(I2CPMessage msg, long timeout)` Send a message, blocking.
    `I2CPMessage` | `poll()` Receive a message, non-blocking
    `void` | `put(I2CPMessage msg)` Send a message, blocking until space is available
    `I2CPMessage` | `take()` Receive a message, blocking until one is available

    - ### Methods inherited from class net.i2p.internal.I2CPMessageQueue

      `close`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### I2CPMessageQueueImpl

          public I2CPMessageQueueImpl(BlockingQueue<I2CPMessage> in,
                                      BlockingQueue<I2CPMessage> out)

  - ### Method Detail

    - #### offer

          public boolean offer(I2CPMessage msg)

      Send a message, nonblocking
      Specified by:
        `offer` in class `I2CPMessageQueue`
      Returns:
        success (false if no space available)

    - #### offer

          public boolean offer(I2CPMessage msg,
                               long timeout)
                        throws InterruptedException

      Send a message, blocking.
      Specified by:
        `offer` in class `I2CPMessageQueue`
      Parameters:
        `timeout` - how long to wait for space (ms)
      Returns:
        success (false if no space available or if timed out)
      Throws:
        `InterruptedException`

    - #### poll

          public I2CPMessage poll()

      Receive a message, non-blocking
      Specified by:
        `poll` in class `I2CPMessageQueue`
      Returns:
        message or null if none available

    - #### put

          public void put(I2CPMessage msg)
                   throws InterruptedException

      Send a message, blocking until space is available
      Specified by:
        `put` in class `I2CPMessageQueue`
      Throws:
        `InterruptedException`

    - #### take

          public I2CPMessage take()
                           throws InterruptedException

      Receive a message, blocking until one is available
      Specified by:
        `take` in class `I2CPMessageQueue`
      Returns:
        message
      Throws:
        `InterruptedException`