Package org.zeromq

## Class ZMQ.Poller

- java.lang.Object
- - org.zeromq.ZMQ.Poller

- Enclosing class:
    ZMQ

      public static class ZMQ.Poller
      extends Object

  Inner class: Poller.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `POLLERR` |
    `static int` | `POLLIN` | These values can be ORed to specify what we want to poll for.
    `static int` | `POLLOUT` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `` | `Poller​(int size)` | Constructor
    `protected` | `Poller​(ZMQ.Context context)` | Class constructor.
    `protected` | `Poller​(ZMQ.Context context, int size)` | Class constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ZMQ.PollItem` | `getItem​(int index)` | Get the PollItem associated with an index.
    `int` | `getNext()` | Get the index for the next position in the poll set size.
    `int` | `getSize()` | Get the current poll set size.
    `ZMQ.Socket` | `getSocket​(int index)` | Get the socket associated with an index.
    `long` | `getTimeout()` | Deprecated. Timeout handling has been moved to the poll() methods.
    `long` | `poll()` | Issue a poll call.
    `int` | `poll​(long tout)` | Issue a poll call, using the specified timeout value.
    `boolean` | `pollerr​(int index)` | Check whether the specified element in the poll set was signalled for error.
    `boolean` | `pollin​(int index)` | Check whether the specified element in the poll set was signalled for input.
    `boolean` | `pollout​(int index)` | Check whether the specified element in the poll set was signalled for output.
    `int` | `register​(SelectableChannel channel)` | Register a Channel for polling on all events.
    `int` | `register​(SelectableChannel channel, int events)` | Register a Channel for polling on the specified events.
    `int` | `register​(ZMQ.PollItem item)` | Register a Channel for polling on the specified events.
    `int` | `register​(ZMQ.Socket socket)` | Register a Socket for polling on all events.
    `int` | `register​(ZMQ.Socket socket, int events)` | Register a Socket for polling on the specified events.
    `protected static int` | `run_poll​(ZMQ.PollItem[] items, int count, long timeout)` | Issue a poll call on the specified 0MQ items.
    `void` | `setTimeout​(long timeout)` | Deprecated. Timeout handling has been moved to the poll() methods.
    `void` | `unregister​(SelectableChannel channel)` | Unregister a Channel for polling on the specified events.
    `void` | `unregister​(ZMQ.Socket socket)` | Unregister a Socket for polling on the specified events.

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

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

- - ### Field Detail

    - #### POLLIN

          public static final int POLLIN

      These values can be ORed to specify what we want to poll for.
      See Also:
        Constant Field Values

    - #### POLLOUT

          public static final int POLLOUT

      See Also:
        Constant Field Values

    - #### POLLERR

          public static final int POLLERR

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Poller

          public Poller​(int size)

      Constructor
      Parameters:
        `size` - the number of Sockets this poller will contain.

    - #### Poller

          protected Poller​(ZMQ.Context context)

      Class constructor.
      Parameters:
        `context` - a 0MQ context previously created.

    - #### Poller

          protected Poller​(ZMQ.Context context,
                           int size)

      Class constructor.
      Parameters:
        `context` - a 0MQ context previously created.
        `size` - the number of Sockets this poller will contain.

  - ### Method Detail

    - #### register

          public int register​(ZMQ.Socket socket)

      Register a Socket for polling on all events.
      Parameters:
        `socket` - the Socket we are registering.
      Returns:
        the index identifying this Socket in the poll set.

    - #### register

          public int register​(SelectableChannel channel)

      Register a Channel for polling on all events.
      Parameters:
        `channel` - the Channel we are registering.
      Returns:
        the index identifying this Channel in the poll set.

    - #### register

          public int register​(ZMQ.Socket socket,
                              int events)

      Register a Socket for polling on the specified events. Automatically grow the internal representation if needed.
      Parameters:
        `socket` - the Socket we are registering.
        `events` - a mask composed by XORing POLLIN, POLLOUT and POLLERR.
      Returns:
        the index identifying this Socket in the poll set.

    - #### register

          public int register​(SelectableChannel channel,
                              int events)

      Register a Channel for polling on the specified events. Automatically grow the internal representation if needed.
      Parameters:
        `channel` - the Channel we are registering.
        `events` - a mask composed by XORing POLLIN, POLLOUT and POLLERR.
      Returns:
        the index identifying this Channel in the poll set.

    - #### register

          public int register​(ZMQ.PollItem item)

      Register a Channel for polling on the specified events. Automatically grow the internal representation if needed.
      Parameters:
        `item` - the PollItem we are registering.
      Returns:
        the index identifying this Channel in the poll set.

    - #### unregister

          public void unregister​(ZMQ.Socket socket)

      Unregister a Socket for polling on the specified events.
      Parameters:
        `socket` - the Socket to be unregistered

    - #### unregister

          public void unregister​(SelectableChannel channel)

      Unregister a Channel for polling on the specified events.
      Parameters:
        `channel` - the Channel to be unregistered

    - #### getSocket

          public ZMQ.Socket getSocket​(int index)

      Get the socket associated with an index.
      Parameters:
        `index` - the desired index.
      Returns:
        the Socket associated with that index (or null).

    - #### getItem

          public ZMQ.PollItem getItem​(int index)

      Get the PollItem associated with an index.
      Parameters:
        `index` - the desired index.
      Returns:
        the PollItem associated with that index (or null).

    - #### getTimeout

          public long getTimeout()

      Deprecated.
      Timeout handling has been moved to the poll() methods.
      Get the current poll timeout.
      Returns:
        the current poll timeout in microseconds.

    - #### setTimeout

          public void setTimeout​(long timeout)

      Deprecated.
      Timeout handling has been moved to the poll() methods.
      Set the poll timeout.
      Parameters:
        `timeout` - the desired poll timeout in microseconds.

    - #### getSize

          public int getSize()

      Get the current poll set size.
      Returns:
        the current poll set size.

    - #### getNext

          public int getNext()

      Get the index for the next position in the poll set size.
      Returns:
        the index for the next position in the poll set size.

    - #### poll

          public long poll()

      Issue a poll call. If the poller's internal timeout value has been set, use that value as timeout; otherwise, block indefinitely.
      Returns:
        how many objects where signalled by poll ().

    - #### poll

          public int poll​(long tout)

      Issue a poll call, using the specified timeout value.

      Since ZeroMQ 3.0, the timeout parameter is in milliseconds, but prior to this the unit was microseconds.

      Parameters:
        `tout` - the timeout, as per zmq_poll if -1, it will block indefinitely until an event happens; if 0, it will return immediately; otherwise, it will wait for at most that many milliseconds/microseconds (see above).
      Returns:
        how many objects where signalled by poll ()
      See Also:
        2.1 docs, 3.0 docs

    - #### pollin

          public boolean pollin​(int index)

      Check whether the specified element in the poll set was signalled for input.
      Parameters:
        `index` -
      Returns:
        true if the element was signalled.

    - #### pollout

          public boolean pollout​(int index)

      Check whether the specified element in the poll set was signalled for output.
      Parameters:
        `index` -
      Returns:
        true if the element was signalled.

    - #### pollerr

          public boolean pollerr​(int index)

      Check whether the specified element in the poll set was signalled for error.
      Parameters:
        `index` -
      Returns:
        true if the element was signalled.

    - #### run_poll

          protected static int run_poll​(ZMQ.PollItem[] items,
                                        int count,
                                        long timeout)

      Issue a poll call on the specified 0MQ items.

      Since ZeroMQ 3.0, the timeout parameter is in milliseconds, but prior to this the unit was microseconds.

      Parameters:
        `items` - an array of PollItem to poll.
        `timeout` - the maximum timeout in milliseconds/microseconds (see above).
      Returns:
        how many objects where signalled by poll.
      See Also:
        2.1 docs, 3.0 docs