abstract class AbstractNioSelector extends java.lang.Object implements NioSelector
| Modifier and Type | Field and Description |
|---|---|
private int |
cancelledKeys |
private static int |
CLEANUP_INTERVAL |
private java.util.concurrent.Executor |
executor
Executor used to execute
Runnables such as channel registration
task. |
private int |
id |
protected static InternalLogger |
logger
Internal Netty logger.
|
private static java.util.concurrent.atomic.AtomicInteger |
nextId |
protected java.nio.channels.Selector |
selector
The NIO
Selector. |
private boolean |
shutdown |
private java.util.concurrent.CountDownLatch |
shutdownLatch |
(package private) java.util.concurrent.CountDownLatch |
startupLatch
Count down to 0 when the I/O thread starts and
thread is set to non-null. |
private java.util.Queue<java.lang.Runnable> |
taskQueue |
protected java.lang.Thread |
thread
If this worker has been started thread will be a reference to the thread
used when starting.
|
protected java.util.concurrent.atomic.AtomicBoolean |
wakenUp
Boolean that controls determines if a blocked Selector.select should
break out of its selection process.
|
| Constructor and Description |
|---|
AbstractNioSelector(java.util.concurrent.Executor executor) |
AbstractNioSelector(java.util.concurrent.Executor executor,
ThreadNameDeterminer determiner) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
cleanUpCancelledKeys() |
protected abstract void |
close(java.nio.channels.SelectionKey k) |
protected abstract java.lang.Runnable |
createRegisterTask(Channel channel,
ChannelFuture future) |
protected void |
increaseCancelledKeys() |
protected boolean |
isIoThread() |
protected abstract ThreadRenamingRunnable |
newThreadRenamingRunnable(int id,
ThreadNameDeterminer determiner) |
private void |
openSelector(ThreadNameDeterminer determiner)
Start the
AbstractNioWorker and return the Selector that will be used for
the AbstractNioChannel's when they get registered |
protected abstract void |
process(java.nio.channels.Selector selector) |
private void |
processTaskQueue() |
void |
rebuildSelector()
Replaces the current
Selector with a new Selector to work around the infamous epoll 100% CPU
bug. |
void |
register(Channel channel,
ChannelFuture future) |
protected void |
registerTask(java.lang.Runnable task) |
void |
run() |
protected int |
select(java.nio.channels.Selector selector) |
void |
shutdown() |
private static final java.util.concurrent.atomic.AtomicInteger nextId
private final int id
protected static final InternalLogger logger
private static final int CLEANUP_INTERVAL
private final java.util.concurrent.Executor executor
Runnables such as channel registration
task.protected volatile java.lang.Thread thread
final java.util.concurrent.CountDownLatch startupLatch
thread is set to non-null.protected volatile java.nio.channels.Selector selector
Selector.protected final java.util.concurrent.atomic.AtomicBoolean wakenUp
private final java.util.Queue<java.lang.Runnable> taskQueue
private volatile int cancelledKeys
private final java.util.concurrent.CountDownLatch shutdownLatch
private volatile boolean shutdown
AbstractNioSelector(java.util.concurrent.Executor executor)
AbstractNioSelector(java.util.concurrent.Executor executor,
ThreadNameDeterminer determiner)
public void register(Channel channel, ChannelFuture future)
register in interface NioSelectorprotected final void registerTask(java.lang.Runnable task)
protected final boolean isIoThread()
public void rebuildSelector()
NioSelectorSelector with a new Selector to work around the infamous epoll 100% CPU
bug.rebuildSelector in interface NioSelectorpublic void run()
run in interface java.lang.Runnableprivate void openSelector(ThreadNameDeterminer determiner)
AbstractNioWorker and return the Selector that will be used for
the AbstractNioChannel's when they get registeredprivate void processTaskQueue()
protected final void increaseCancelledKeys()
protected final boolean cleanUpCancelledKeys()
throws java.io.IOException
java.io.IOExceptionpublic void shutdown()
shutdown in interface NioSelectorprotected abstract void process(java.nio.channels.Selector selector)
throws java.io.IOException
java.io.IOExceptionprotected int select(java.nio.channels.Selector selector)
throws java.io.IOException
java.io.IOExceptionprotected abstract void close(java.nio.channels.SelectionKey k)
protected abstract ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner)
protected abstract java.lang.Runnable createRegisterTask(Channel channel, ChannelFuture future)