Class ZMQ.Poller
java.lang.Object
org.zeromq.ZMQ.Poller
- All Implemented Interfaces:
Closeable, AutoCloseable
- Enclosing class:
ZMQ
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ZMQ.Contextprivate List<ZMQ.PollItem> static final intFor standard sockets, this flag is passed throughZMQ.poll(Selector, zmq.poll.PollItem[], long)to the underlying poll() system call and generally means that some sort of error condition is present on the socket specified by fd.static final intFor ØMQ sockets, at least one message may be received from the socket without blocking.static final intFor ØMQ sockets, at least one message may be sent to the socket without blocking.private final Selectorprivate static final intprivate static final intprivate long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPoller(ZMQ.Context context) Class constructor.protectedPoller(ZMQ.Context context, int size) Class constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getItem(int index) Get the PollItem associated with an index.intgetNext()Deprecated.use getSize insteadintgetSize()Get the current poll set size.getSocket(int index) Get the socket associated with an index.longDeprecated.Timeout handling has been moved to the poll() methods.intpoll()Issue a poll call.intpoll(long tout) Issue a poll call, using the specified timeout value.booleanpollerr(int index) Check whether the specified element in the poll set was signaled for error.booleanpollin(int index) Check whether the specified element in the poll set was signaled for input.booleanpollout(int index) Check whether the specified element in the poll set was signaled for output.intregister(SelectableChannel channel) Register a Channel for polling on all events.intregister(SelectableChannel channel, int events) Register a Socket for polling on the specified events.intregister(ZMQ.PollItem item) Register a Channel for polling on the specified events.intregister(ZMQ.Socket socket) Register a Socket for polling on all events.intregister(ZMQ.Socket socket, int events) Register a Socket for polling on the specified events.private intregisterInternal(ZMQ.PollItem item) Register a Socket for polling on the specified events.voidsetTimeout(long timeout) Deprecated.Timeout handling has been moved to the poll() methods.voidunregister(SelectableChannel channel) Unregister a Socket for polling on the specified events.voidunregister(ZMQ.Socket socket) Unregister a Socket for polling on the specified events.private voidunregisterInternal(Object socket) Unregister a Socket for polling on the specified events.
-
Field Details
-
POLLIN
public static final int POLLINFor ØMQ sockets, at least one message may be received from the socket without blocking.
For standard sockets this is equivalent to the POLLIN flag of the poll() system call and generally means that at least one byte of data may be read from fd without blocking.- See Also:
-
POLLOUT
public static final int POLLOUTFor ØMQ sockets, at least one message may be sent to the socket without blocking.
For standard sockets this is equivalent to the POLLOUT flag of the poll() system call and generally means that at least one byte of data may be written to fd without blocking.- See Also:
-
POLLERR
public static final int POLLERRFor standard sockets, this flag is passed throughZMQ.poll(Selector, zmq.poll.PollItem[], long)to the underlying poll() system call and generally means that some sort of error condition is present on the socket specified by fd.
For ØMQ sockets this flag has no effect if set in events, and shall never be returned in revents byZMQ.poll(Selector, zmq.poll.PollItem[], long).- See Also:
-
SIZE_DEFAULT
private static final int SIZE_DEFAULT- See Also:
-
SIZE_INCREMENT
private static final int SIZE_INCREMENT- See Also:
-
selector
-
context
-
items
-
timeout
private long timeout
-
-
Constructor Details
-
Poller
Class constructor.- Parameters:
context- a 0MQ context previously created.size- the number of Sockets this poller will contain.
-
Poller
Class constructor.- Parameters:
context- a 0MQ context previously created.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
register
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
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
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
Register a Socket 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
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.
-
registerInternal
Register a Socket 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 Socket in the poll set.
-
unregister
Unregister a Socket for polling on the specified events.- Parameters:
socket- the Socket to be unregistered
-
unregister
Unregister a Socket for polling on the specified events.- Parameters:
channel- the Socket to be unregistered
-
unregisterInternal
Unregister a Socket for polling on the specified events.- Parameters:
socket- the Socket to be unregistered
-
getItem
Get the PollItem associated with an index.- Parameters:
index- the desired index.- Returns:
- the PollItem associated with that index (or null).
-
getSocket
Get the socket associated with an index.- Parameters:
index- the desired index.- Returns:
- the Socket associated with that index (or null).
-
getTimeout
Deprecated.Timeout handling has been moved to the poll() methods.Get the current poll timeout.- Returns:
- the current poll timeout in milliseconds.
-
setTimeout
Deprecated.Timeout handling has been moved to the poll() methods.Set the poll timeout.- Parameters:
timeout- the desired poll timeout in milliseconds.
-
getSize
public int getSize()Get the current poll set size.- Returns:
- the current poll set size.
-
getNext
Deprecated.use getSize insteadGet 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 int 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 signaled 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 signaled by poll ()
- See Also:
-
pollin
public boolean pollin(int index) Check whether the specified element in the poll set was signaled for input.- Parameters:
index- of element- Returns:
- true if the element was signaled.
-
pollout
public boolean pollout(int index) Check whether the specified element in the poll set was signaled for output.- Parameters:
index- of element- Returns:
- true if the element was signaled.
-
pollerr
public boolean pollerr(int index) Check whether the specified element in the poll set was signaled for error.- Parameters:
index- of element- Returns:
- true if the element was signaled.
-