Package org.zeromq

Class 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.
    • 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