Top Description Fields Constructors Methods
org.xnio

public abstract Class XnioIoThread

extends Thread
implements XnioExecutor, XnioIoFactory
Class Inheritance
All Implemented Interfaces
org.xnio.XnioIoFactory, org.xnio.XnioExecutor, java.util.concurrent.Executor
Annotations
@SuppressWarnings:unused
Imports
java.io.IOException, java.net.InetAddress, .InetSocketAddress, .SocketAddress, .UnknownHostException, org.wildfly.common.Assert, org.xnio.channels.AssembledStreamChannel, .BoundChannel, .StreamChannel, .StreamSinkChannel, .StreamSourceChannel

An XNIO thread.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private static final InetSocketAddress
private final int
private final XnioWorker
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
protected
XnioIoThread(final XnioWorker
the XNIO worker to associate with
worker
,
final int
the thread number
number
)

Construct a new instance.

protected
XnioIoThread(final XnioWorker
the XNIO worker to associate with
worker
,
final int
the thread number
number
,
final String
the thread name
name
)

Construct a new instance.

protected
XnioIoThread(final XnioWorker
the XNIO worker to associate with
worker
,
final int
the thread number
number
,
final ThreadGroup
the thread group
group
,
final String
the thread name
name
)

Construct a new instance.

protected
XnioIoThread(final XnioWorker
the XNIO worker to associate with
worker
,
final int
the thread number
number
,
final ThreadGroup
the thread group
group
,
final String
the thread name
name
,
final long
the thread stack size
stackSize
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
protected IoFuture<MessageConnection>

Returns:

the future connection
acceptLocalMessageConnection
(LocalSocketAddress
the destination (bind) address
destination
,
ChannelListener<? super MessageConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implementation helper method to accept a local (UNIX domain) datagram connection.

protected IoFuture<StreamConnection>

Returns:

the future connection
acceptLocalStreamConnection
(LocalSocketAddress
the destination (bind) address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implementation helper method to accept a local (UNIX domain) stream connection.

public IoFuture<MessageConnection>
acceptMessageConnection(final SocketAddress
the destination (bind) address
destination
,
final ChannelListener<? super MessageConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
final ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
final OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.acceptMessageConnection.

Accept a message connection at a destination address.

public IoFuture<StreamConnection>
acceptStreamConnection(SocketAddress
the destination (bind) address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.acceptStreamConnection.

Accept a stream connection at a destination address.

protected IoFuture<StreamConnection>

Returns:

the future connection
acceptTcpStreamConnection
(InetSocketAddress
the destination (bind) address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implementation helper method to accept a TCP connection.

public ChannelPipe<StreamChannel, StreamChannel>
createFullDuplexPipe()

Implements org.xnio.XnioIoFactory.createFullDuplexPipe.

Create a two-way stream pipe.

public ChannelPipe<StreamConnection, StreamConnection>
public ChannelPipe<StreamConnection, StreamConnection>
createFullDuplexPipeConnection(final XnioIoFactory
the peer to use for controlling the remote (right) side
peer
)

Implements org.xnio.XnioIoFactory.createFullDuplexPipeConnection.

Create a two-way stream pipe.

public ChannelPipe<StreamSourceChannel, StreamSinkChannel>
createHalfDuplexPipe()

Implements org.xnio.XnioIoFactory.createHalfDuplexPipe.

Create a one-way stream pipe.

public ChannelPipe<StreamSourceChannel, StreamSinkChannel>
createHalfDuplexPipe(final XnioIoFactory
the peer to use for the sink (right) side
peer
)

Implements org.xnio.XnioIoFactory.createHalfDuplexPipe.

Create a one-way stream pipe.

public static XnioIoThread

Returns:

the current XNIO thread
currentThread
()

Hides java.lang.Thread.currentThread.

Get the current XNIO thread.

public int

Returns:

the number of this thread
getNumber
()

Get the number of this thread.

public XnioWorker

Returns:

the XNIO worker
getWorker
()

Get the XNIO worker associated with this thread.

private IoFuture<StreamConnection>
internalOpenTcpStreamConnection(InetSocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

protected IoFuture<MessageConnection>

Returns:

the future result of this operation
openLocalMessageConnection
(LocalSocketAddress
the bind address
bindAddress
,
LocalSocketAddress
the destination address
destinationAddress
,
ChannelListener<? super MessageConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
OptionMap
the option map
optionMap
)

Implementation helper method to connect to a local (UNIX domain) server.

protected IoFuture<StreamConnection>

Returns:

the future result of this operation
openLocalStreamConnection
(LocalSocketAddress
the bind address
bindAddress
,
LocalSocketAddress
the destination address
destinationAddress
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implementation helper method to connect to a local (UNIX domain) server.

public IoFuture<MessageConnection>
openMessageConnection(final SocketAddress
the destination address
destination
,
final ChannelListener<? super MessageConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
final OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openMessageConnection.

Connect to a remote message server.

public IoFuture<StreamConnection>
openStreamConnection(SocketAddress
the destination address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server.

public IoFuture<StreamConnection>
openStreamConnection(SocketAddress
the destination address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server.

public IoFuture<StreamConnection>
openStreamConnection(SocketAddress
the local address to bind to
bindAddress
,
SocketAddress
the destination address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server.

protected IoFuture<StreamConnection>

Returns:

the future result of this operation
openTcpStreamConnection
(InetSocketAddress
the bind address
bindAddress
,
InetSocketAddress
the destination address
destinationAddress
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implementation helper method to connect to a TCP server.

public static XnioIoThread

Returns:

the current XNIO thread
requireCurrentThread
()

Get the current XNIO thread.

Inherited from java.lang.Thread:
activeCountcheckAccessclonedumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitrunsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

ANY_INET_ADDRESSback to summary
private static final InetSocketAddress ANY_INET_ADDRESS
numberback to summary
private final int number
workerback to summary
private final XnioWorker worker

Constructor Detail

XnioIoThreadback to summary
protected XnioIoThread(final XnioWorker worker, final int number)

Construct a new instance.

Parameters
worker:XnioWorker

the XNIO worker to associate with

number:int

the thread number

XnioIoThreadback to summary
protected XnioIoThread(final XnioWorker worker, final int number, final String name)

Construct a new instance.

Parameters
worker:XnioWorker

the XNIO worker to associate with

number:int

the thread number

name:String

the thread name

XnioIoThreadback to summary
protected XnioIoThread(final XnioWorker worker, final int number, final ThreadGroup group, final String name)

Construct a new instance.

Parameters
worker:XnioWorker

the XNIO worker to associate with

number:int

the thread number

group:ThreadGroup

the thread group

name:String

the thread name

XnioIoThreadback to summary
protected XnioIoThread(final XnioWorker worker, final int number, final ThreadGroup group, final String name, final long stackSize)

Construct a new instance.

Parameters
worker:XnioWorker

the XNIO worker to associate with

number:int

the thread number

group:ThreadGroup

the thread group

name:String

the thread name

stackSize:long

the thread stack size

Method Detail

acceptLocalMessageConnectionback to summary
protected IoFuture<MessageConnection> acceptLocalMessageConnection(LocalSocketAddress destination, ChannelListener<? super MessageConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implementation helper method to accept a local (UNIX domain) datagram connection.

Parameters
destination:LocalSocketAddress

the destination (bind) address

openListener:ChannelListener<? super MessageConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the acceptor is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<MessageConnection>

the future connection

acceptLocalStreamConnectionback to summary
protected IoFuture<StreamConnection> acceptLocalStreamConnection(LocalSocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implementation helper method to accept a local (UNIX domain) stream connection.

Parameters
destination:LocalSocketAddress

the destination (bind) address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the acceptor is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future connection

acceptMessageConnectionback to summary
public IoFuture<MessageConnection> acceptMessageConnection(final SocketAddress destination, final ChannelListener<? super MessageConnection> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap)

Implements org.xnio.XnioIoFactory.acceptMessageConnection.

Doc from org.xnio.XnioIoFactory.acceptMessageConnection.

Accept a message connection at a destination address. If a wildcard address is specified, then a destination address is chosen in a manner specific to the OS and/or channel type. If an open listener is used, the channel should not be accessed via the returned IoFuture, and vice-versa.

Parameters
destination:SocketAddress

the destination (bind) address

openListener:ChannelListener<? super MessageConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the acceptor is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<MessageConnection>

the future connection

acceptStreamConnectionback to summary
public IoFuture<StreamConnection> acceptStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implements org.xnio.XnioIoFactory.acceptStreamConnection.

Doc from org.xnio.XnioIoFactory.acceptStreamConnection.

Accept a stream connection at a destination address. If a wildcard address is specified, then a destination address is chosen in a manner specific to the OS and/or channel type.

Parameters
destination:SocketAddress

the destination (bind) address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the acceptor is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future connection

acceptTcpStreamConnectionback to summary
protected IoFuture<StreamConnection> acceptTcpStreamConnection(InetSocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implementation helper method to accept a TCP connection.

Parameters
destination:InetSocketAddress

the destination (bind) address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the acceptor is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future connection

createFullDuplexPipeback to summary
public ChannelPipe<StreamChannel, StreamChannel> createFullDuplexPipe() throws IOException

Implements org.xnio.XnioIoFactory.createFullDuplexPipe.

Doc from org.xnio.XnioIoFactory.createFullDuplexPipe.

Create a two-way stream pipe.

Returns:ChannelPipe<StreamChannel, StreamChannel>

the created pipe

Exceptions
IOException:
if the pipe could not be created
createFullDuplexPipeConnectionback to summary
public ChannelPipe<StreamConnection, StreamConnection> createFullDuplexPipeConnection() throws IOException

Implements org.xnio.XnioIoFactory.createFullDuplexPipeConnection.

Doc from org.xnio.XnioIoFactory.createFullDuplexPipeConnection.

Create a two-way stream pipe.

Returns:ChannelPipe<StreamConnection, StreamConnection>

the created pipe

Exceptions
IOException:
if the pipe could not be created
createFullDuplexPipeConnectionback to summary
public ChannelPipe<StreamConnection, StreamConnection> createFullDuplexPipeConnection(final XnioIoFactory peer) throws IOException

Implements org.xnio.XnioIoFactory.createFullDuplexPipeConnection.

Doc from org.xnio.XnioIoFactory.createFullDuplexPipeConnection.

Create a two-way stream pipe. The left side will be associated with this factory, and the right side will be associated with the given peer.

Parameters
peer:XnioIoFactory

the peer to use for controlling the remote (right) side

Returns:ChannelPipe<StreamConnection, StreamConnection>

the created pipe

Exceptions
IOException:
if the pipe could not be created
createHalfDuplexPipeback to summary
public ChannelPipe<StreamSourceChannel, StreamSinkChannel> createHalfDuplexPipe() throws IOException

Implements org.xnio.XnioIoFactory.createHalfDuplexPipe.

Doc from org.xnio.XnioIoFactory.createHalfDuplexPipe.

Create a one-way stream pipe.

Returns:ChannelPipe<StreamSourceChannel, StreamSinkChannel>

the created pipe

Exceptions
IOException:
if the pipe could not be created
createHalfDuplexPipeback to summary
public ChannelPipe<StreamSourceChannel, StreamSinkChannel> createHalfDuplexPipe(final XnioIoFactory peer) throws IOException

Implements org.xnio.XnioIoFactory.createHalfDuplexPipe.

Doc from org.xnio.XnioIoFactory.createHalfDuplexPipe.

Create a one-way stream pipe. The left (source) side will be associated with this factory, and the right (sink) side will be associated with the given peer.

Parameters
peer:XnioIoFactory

the peer to use for the sink (right) side

Returns:ChannelPipe<StreamSourceChannel, StreamSinkChannel>

the created pipe

Exceptions
IOException:
if the pipe could not be created
currentThreadback to summary
public static XnioIoThread currentThread()

Hides java.lang.Thread.currentThread.

Get the current XNIO thread. If the current thread is not an XNIO thread, null is returned.

Returns:XnioIoThread

the current XNIO thread

getNumberback to summary
public int getNumber()

Get the number of this thread. In each XNIO worker, every IO thread is given a unique, sequential number.

Returns:int

the number of this thread

getWorkerback to summary
public XnioWorker getWorker()

Get the XNIO worker associated with this thread.

Returns:XnioWorker

the XNIO worker

internalOpenTcpStreamConnectionback to summary
private IoFuture<StreamConnection> internalOpenTcpStreamConnection(InetSocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
openLocalMessageConnectionback to summary
protected IoFuture<MessageConnection> openLocalMessageConnection(LocalSocketAddress bindAddress, LocalSocketAddress destinationAddress, ChannelListener<? super MessageConnection> openListener, OptionMap optionMap)

Implementation helper method to connect to a local (UNIX domain) server.

Parameters
bindAddress:LocalSocketAddress

the bind address

destinationAddress:LocalSocketAddress

the destination address

openListener:ChannelListener<? super MessageConnection>

the listener which will be notified when the channel is open, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<MessageConnection>

the future result of this operation

openLocalStreamConnectionback to summary
protected IoFuture<StreamConnection> openLocalStreamConnection(LocalSocketAddress bindAddress, LocalSocketAddress destinationAddress, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implementation helper method to connect to a local (UNIX domain) server.

Parameters
bindAddress:LocalSocketAddress

the bind address

destinationAddress:LocalSocketAddress

the destination address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the channel is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future result of this operation

openMessageConnectionback to summary
public IoFuture<MessageConnection> openMessageConnection(final SocketAddress destination, final ChannelListener<? super MessageConnection> openListener, final OptionMap optionMap)

Implements org.xnio.XnioIoFactory.openMessageConnection.

Doc from org.xnio.XnioIoFactory.openMessageConnection.

Connect to a remote message server. The protocol family is determined by the type of the socket address given. If an open listener is used, the channel should not be accessed via the returned IoFuture, and vice-versa.

Parameters
destination:SocketAddress

the destination address

openListener:ChannelListener<? super MessageConnection>

the listener which will be notified when the channel is open, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<MessageConnection>

the future result of this operation

openStreamConnectionback to summary
public IoFuture<StreamConnection> openStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, OptionMap optionMap)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Doc from org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server. The protocol family is determined by the type of the socket address given. If an open listener is used, the channel should not be accessed via the returned IoFuture, and vice-versa.

Parameters
destination:SocketAddress

the destination address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future result of this operation

openStreamConnectionback to summary
public IoFuture<StreamConnection> openStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Doc from org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server. The protocol family is determined by the type of the socket address given. If an open listener is used, the channel should not be accessed via the returned IoFuture, and vice-versa.

Parameters
destination:SocketAddress

the destination address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the channel is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future result of this operation

openStreamConnectionback to summary
public IoFuture<StreamConnection> openStreamConnection(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Doc from org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server. The protocol family is determined by the type of the socket addresses given (which must match). If an open listener is used, the channel should not be accessed via the returned IoFuture, and vice-versa.

Parameters
bindAddress:SocketAddress

the local address to bind to

destination:SocketAddress

the destination address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the channel is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future result of this operation

openTcpStreamConnectionback to summary
protected IoFuture<StreamConnection> openTcpStreamConnection(InetSocketAddress bindAddress, InetSocketAddress destinationAddress, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)

Implementation helper method to connect to a TCP server.

Parameters
bindAddress:InetSocketAddress

the bind address

destinationAddress:InetSocketAddress

the destination address

openListener:ChannelListener<? super StreamConnection>

the listener which will be notified when the channel is open, or null for none

bindListener:ChannelListener<? super BoundChannel>

the listener which will be notified when the channel is bound, or null for none

optionMap:OptionMap

the option map

Returns:IoFuture<StreamConnection>

the future result of this operation

requireCurrentThreadback to summary
public static XnioIoThread requireCurrentThread() throws IllegalStateException

Get the current XNIO thread. If the current thread is not an XNIO thread, an IllegalStateException is thrown.

Returns:XnioIoThread

the current XNIO thread

Exceptions
IllegalStateException:
if the current thread is not an XNIO thread