public static class ZMQ.Context
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicBoolean |
closed |
private Ctx |
ctx |
Modifier | Constructor and Description |
---|---|
protected |
Context(int ioThreads)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Destroys the ØMQ context context.
|
boolean |
close(java.nio.channels.Selector selector)
Closes a Selector that was created within this context.
|
boolean |
getBlocky()
Deprecated.
use
isBlocky() instead |
int |
getIOThreads()
The size of the 0MQ thread pool to handle I/O operations.
|
boolean |
getIPv6() |
int |
getMaxSockets()
The maximum number of sockets allowed on the context
|
java.lang.Thread.UncaughtExceptionHandler |
getNotificationExceptionHandler() |
java.lang.Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler() |
boolean |
isBlocky() |
boolean |
isClosed() |
boolean |
isIPv6() |
boolean |
isTerminated()
Returns true if terminate() has been called on ctx.
|
ZMQ.Poller |
poller()
Create a new Poller within this context, with a default size.
|
ZMQ.Poller |
poller(int size)
Create a new Poller within this context, with a specified initial size.
|
java.nio.channels.Selector |
selector()
Create a new Selector within this context.
|
boolean |
setBlocky(boolean block) |
boolean |
setIOThreads(int ioThreads)
Set the size of the 0MQ thread pool to handle I/O operations.
|
boolean |
setIPv6(boolean ipv6) |
boolean |
setMaxSockets(int maxSockets)
Sets the maximum number of sockets allowed on the context
|
void |
setNotificationExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
In
Poller.run() , some non-fatal exceptions can be thrown. |
void |
setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Set the handler invoked when a
Poller abruptly terminates due to an uncaught exception. |
ZMQ.Socket |
socket(int type)
Deprecated.
|
ZMQ.Socket |
socket(SocketType type)
Creates a ØMQ socket within the specified context and return an opaque handle to the newly created socket.
|
void |
term()
This is an explicit "destructor".
|
private final java.util.concurrent.atomic.AtomicBoolean closed
private final Ctx ctx
protected Context(int ioThreads)
ioThreads
- size of the threads pool to handle I/O operations.public boolean isTerminated()
public int getIOThreads()
public boolean setIOThreads(int ioThreads)
public int getMaxSockets()
public boolean setMaxSockets(int maxSockets)
@Deprecated public boolean getBlocky()
isBlocky()
insteadpublic boolean isBlocky()
public boolean setBlocky(boolean block)
public boolean isIPv6()
public boolean getIPv6()
public boolean setIPv6(boolean ipv6)
public void setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Poller
abruptly terminates due to an uncaught exception.
It default to the value of Thread.getDefaultUncaughtExceptionHandler()
handler
- The object to use as this thread's uncaught exception handler. If null then this thread has no explicit handler.public java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
Poller
abruptly terminates due to an uncaught exception.public void setNotificationExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Poller.run()
, some non-fatal exceptions can be thrown. This handler will be notified, so they can
be logged.
Default to Throwable.printStackTrace()
handler
- The object to use as this thread's handler for recoverable exceptions notifications.public java.lang.Thread.UncaughtExceptionHandler getNotificationExceptionHandler()
public void term()
public boolean isClosed()
public ZMQ.Socket socket(SocketType type)
ZMQ.Socket.connect(String)
,
or at least one endpoint must be created for accepting incoming connections with ZMQ.Socket.bind(String)
.type
- the socket type.@Deprecated public ZMQ.Socket socket(int type)
public java.nio.channels.Selector selector()
public boolean close(java.nio.channels.Selector selector)
selector
- the Selector to close.public ZMQ.Poller poller()
ZMQ.Poller.close()
public ZMQ.Poller poller(int size)
ZMQ.Poller.close()
size
- the poller initial size.public void close()
ZMQ.Socket.close()
, any further operations on sockets
open within context shall fail with an error code of ETERM.ZMQ.Socket.close()
.ZMQ.Socket.send(java.lang.String)
have either
been physically transferred to a network peer,
or the socket's linger period set with the ZMQ.Socket.setLinger(int)
socket option has expired.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable