Package zmq
Class Ctx
- java.lang.Object
-
- zmq.Ctx
-
public class Ctx extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Ctx.ChannelForwardHolder
A class that holds the informations needed to forward channel in monitor sockets.static class
Ctx.Endpoint
private static class
Ctx.PendingConnection
private static class
Ctx.Side
-
Field Summary
Fields Modifier and Type Field Description private boolean
active
private boolean
blocky
private java.util.Deque<java.lang.Integer>
emptySlots
private java.util.Map<java.lang.String,Ctx.Endpoint>
endpoints
private java.util.concurrent.locks.Lock
endpointsSync
private Errno
errno
private java.lang.Thread.UncaughtExceptionHandler
exhandler
private java.lang.Thread.UncaughtExceptionHandler
exnotification
private Ctx.ChannelForwardHolder
forwardHolder
private int
ioThreadCount
private java.util.List<IOThread>
ioThreads
private boolean
ipv6
private static java.util.concurrent.atomic.AtomicInteger
maxSocketId
private int
maxSockets
private java.util.concurrent.locks.Lock
optSync
private MultiMap<java.lang.String,Ctx.PendingConnection>
pendingConnections
private Reaper
reaper
private static int
REAPER_TID
private java.util.List<java.nio.channels.Selector>
selectors
private java.util.concurrent.locks.Lock
selectorSync
private int
slotCount
private IMailbox[]
slots
private java.util.concurrent.locks.Lock
slotSync
private java.util.List<SocketBase>
sockets
private java.util.concurrent.atomic.AtomicBoolean
starting
(package private) static int
TERM_TID
private boolean
terminating
private Mailbox
termMailbox
private static int
WAIT_FOREVER
-
Constructor Summary
Constructors Constructor Description Ctx()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
checkTag()
Deprecated.useisActive()
instead(package private) IOThread
chooseIoThread(long affinity)
private void
cleanForwarded()
Clean all empty referencesboolean
closeSelector(java.nio.channels.Selector selector)
private void
connectInprocSockets(SocketBase bindSocket, Options bindOptions, Ctx.PendingConnection pendingConnection, Ctx.Side side)
(package private) void
connectPending(java.lang.String addr, SocketBase bindSocket)
java.nio.channels.Selector
createSelector()
SocketBase
createSocket(int type)
private void
destroy()
(package private) void
destroySocket(SocketBase socket)
Errno
errno()
(package private) Ctx.Endpoint
findEndpoint(java.lang.String addr)
(package private) int
forwardChannel(java.nio.channels.SelectableChannel channel)
Forward a channel in a monitor socket.int
get(int option)
(package private) java.nio.channels.SelectableChannel
getForwardedChannel(java.lang.Integer handle)
Retrieve a channel, using the handle returned byforwardChannel(SelectableChannel)
.java.lang.Thread.UncaughtExceptionHandler
getNotificationExceptionHandler()
(package private) ZObject
getReaper()
java.lang.Thread.UncaughtExceptionHandler
getUncaughtExceptionHandler()
private void
initSlots()
boolean
isActive()
(package private) void
pendConnection(java.lang.String addr, Ctx.Endpoint endpoint, Pipe[] pipes)
(package private) boolean
registerEndpoint(java.lang.String addr, Ctx.Endpoint endpoint)
(package private) void
sendCommand(int tid, Command command)
boolean
set(int option, int optval)
void
setNotificationExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
InPoller.run()
, some non-fatal exceptions can be thrown.void
setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Set the handler invoked when aPoller
abruptly terminates due to an uncaught exception.(package private) void
shutdown()
void
terminate()
(package private) boolean
unregisterEndpoint(java.lang.String addr, SocketBase socket)
(package private) void
unregisterEndpoints(SocketBase socket)
-
-
-
Field Detail
-
WAIT_FOREVER
private static final int WAIT_FOREVER
- See Also:
- Constant Field Values
-
active
private boolean active
-
sockets
private final java.util.List<SocketBase> sockets
-
emptySlots
private final java.util.Deque<java.lang.Integer> emptySlots
-
starting
private final java.util.concurrent.atomic.AtomicBoolean starting
-
terminating
private boolean terminating
-
slotSync
private final java.util.concurrent.locks.Lock slotSync
-
selectors
private final java.util.List<java.nio.channels.Selector> selectors
-
reaper
private Reaper reaper
-
ioThreads
private final java.util.List<IOThread> ioThreads
-
slotCount
private int slotCount
-
slots
private IMailbox[] slots
-
termMailbox
private final Mailbox termMailbox
-
endpoints
private final java.util.Map<java.lang.String,Ctx.Endpoint> endpoints
-
endpointsSync
private final java.util.concurrent.locks.Lock endpointsSync
-
maxSocketId
private static java.util.concurrent.atomic.AtomicInteger maxSocketId
-
maxSockets
private int maxSockets
-
ioThreadCount
private int ioThreadCount
-
blocky
private boolean blocky
-
optSync
private final java.util.concurrent.locks.Lock optSync
-
selectorSync
private final java.util.concurrent.locks.Lock selectorSync
-
TERM_TID
static final int TERM_TID
- See Also:
- Constant Field Values
-
REAPER_TID
private static final int REAPER_TID
- See Also:
- Constant Field Values
-
pendingConnections
private final MultiMap<java.lang.String,Ctx.PendingConnection> pendingConnections
-
ipv6
private boolean ipv6
-
errno
private final Errno errno
-
exhandler
private java.lang.Thread.UncaughtExceptionHandler exhandler
-
exnotification
private java.lang.Thread.UncaughtExceptionHandler exnotification
-
forwardHolder
private Ctx.ChannelForwardHolder forwardHolder
-
-
Method Detail
-
destroy
private void destroy() throws java.io.IOException
- Throws:
java.io.IOException
-
isActive
public boolean isActive()
- Returns:
- false if
terminate()
terminate() has been called.
-
checkTag
@Deprecated public boolean checkTag()
Deprecated.useisActive()
instead- Returns:
- false if
terminate()
terminate() has been called.
-
terminate
public void terminate()
-
shutdown
final void shutdown()
-
setUncaughtExceptionHandler
public void setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Set the handler invoked when aPoller
abruptly terminates due to an uncaught exception.It default to the value of
Thread.getDefaultUncaughtExceptionHandler()
- Parameters:
handler
- The object to use as this thread's uncaught exception handler. If null then this thread has no explicit handler.
-
getUncaughtExceptionHandler
public java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
- Returns:
- The handler invoked when a
Poller
abruptly terminates due to an uncaught exception.
-
setNotificationExceptionHandler
public void setNotificationExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
InPoller.run()
, some non-fatal exceptions can be thrown. This handler will be notified, so they can be logged.Default to
Throwable.printStackTrace()
- Parameters:
handler
- The object to use as this thread's handler for recoverable exceptions notifications.
-
getNotificationExceptionHandler
public java.lang.Thread.UncaughtExceptionHandler getNotificationExceptionHandler()
- Returns:
- The handler invoked when a non-fatal exceptions is thrown in zmq.poll.Poller#run()
-
set
public boolean set(int option, int optval)
-
get
public int get(int option)
-
createSocket
public SocketBase createSocket(int type)
-
initSlots
private void initSlots()
-
destroySocket
void destroySocket(SocketBase socket)
-
createSelector
public java.nio.channels.Selector createSelector()
-
closeSelector
public boolean closeSelector(java.nio.channels.Selector selector)
-
getReaper
ZObject getReaper()
-
sendCommand
void sendCommand(int tid, Command command)
-
chooseIoThread
IOThread chooseIoThread(long affinity)
-
registerEndpoint
boolean registerEndpoint(java.lang.String addr, Ctx.Endpoint endpoint)
-
unregisterEndpoint
boolean unregisterEndpoint(java.lang.String addr, SocketBase socket)
-
unregisterEndpoints
void unregisterEndpoints(SocketBase socket)
-
findEndpoint
Ctx.Endpoint findEndpoint(java.lang.String addr)
-
pendConnection
void pendConnection(java.lang.String addr, Ctx.Endpoint endpoint, Pipe[] pipes)
-
connectPending
void connectPending(java.lang.String addr, SocketBase bindSocket)
-
connectInprocSockets
private void connectInprocSockets(SocketBase bindSocket, Options bindOptions, Ctx.PendingConnection pendingConnection, Ctx.Side side)
-
errno
public Errno errno()
-
forwardChannel
int forwardChannel(java.nio.channels.SelectableChannel channel)
Forward a channel in a monitor socket.- Parameters:
channel
- a channel to forward- Returns:
- the handle of the channel to be forwarded, used to retrieve it in
getForwardedChannel(Integer)
-
getForwardedChannel
java.nio.channels.SelectableChannel getForwardedChannel(java.lang.Integer handle)
Retrieve a channel, using the handle returned byforwardChannel(SelectableChannel)
. As WeakReference are used, if the channel was discarded and a GC ran, it will not be found and this method will return null.- Parameters:
handle
-- Returns:
-
cleanForwarded
private void cleanForwarded()
Clean all empty references
-
-