public class NioManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
NioManager.SelectStrategy
Handles doing a select on a selector.
|
(package private) class |
NioManager.WorkAroundSelectSpin
Workaround for the selector spin bug.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicInteger |
registeredKeys |
protected int |
selectCounter |
protected boolean |
selecting |
private java.nio.channels.Selector |
selector |
(package private) NioManager.SelectStrategy |
selectStrategy
Set the "hawtdispatch.workaround-select-spin" System property to "true" if your
seeing the 100% CPU usage in the Selector.select() call.
|
private boolean |
TRACE |
private java.util.LinkedList<java.lang.String> |
traces |
protected java.util.concurrent.atomic.AtomicInteger |
wakeupCounter |
| Constructor and Description |
|---|
NioManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(java.nio.channels.SelectionKey key) |
int |
getRegisteredKeyCount() |
private int |
processSelected() |
NioAttachment |
register(java.nio.channels.SelectableChannel channel,
int interestOps) |
int |
select(long timeout)
Selects ready sources, potentially blocking.
|
void |
shutdown() |
protected void |
trace(java.lang.String str,
java.lang.Object... args) |
boolean |
wakeupIfSelecting() |
final NioManager.SelectStrategy selectStrategy
private java.nio.channels.Selector selector
protected final java.util.concurrent.atomic.AtomicInteger wakeupCounter
protected volatile int selectCounter
private final java.util.concurrent.atomic.AtomicInteger registeredKeys
protected volatile boolean selecting
private final boolean TRACE
private final java.util.LinkedList<java.lang.String> traces
public NioManager()
throws java.io.IOException
java.io.IOExceptionpublic boolean wakeupIfSelecting()
public int select(long timeout)
throws java.io.IOException
timeout - A negative value cause the select to block until a source is
ready, 0 will do a non blocking select. Otherwise the select
will block up to timeout in milliseconds waiting for a source
to become ready.java.io.IOExceptionprivate int processSelected()
public void shutdown()
throws java.io.IOException
java.io.IOExceptionprotected void trace(java.lang.String str,
java.lang.Object... args)
public NioAttachment register(java.nio.channels.SelectableChannel channel, int interestOps) throws java.nio.channels.ClosedChannelException
java.nio.channels.ClosedChannelExceptionpublic int getRegisteredKeyCount()
public void cancel(java.nio.channels.SelectionKey key)