code: protected int poll(final long timeout, final boolean dispatchEvents)
      {
          // get all the raw items
          final Set<PollItem> pollItems = new HashSet<>();
          for (CompositePollItem it : all) {
              pollItems.add(it.item());
          }
          // polling time
          final int rc = poll(selector, timeout, pollItems);
  
          if (!dispatchEvents) {
              // raw result
              return rc;
          }
  
          if (dispatch(all, pollItems.size())) {
              // returns event counts after dispatch if everything went fine
              return rc;
          }
          // error in dispatching
          return -1;
      }
docs: Issue a poll call, using the specified timeout value.
  
  @param timeout           the timeout, as per zmq_poll ();
  @param dispatchEvents    true to dispatch events using items handler and the global one.
  @see "http://api.zeromq.org/3-0:zmq-poll"
  @return how many objects where signaled by poll ()