public class SelectorKernel extends AbstractKernel
Modifier and Type | Class and Description |
---|---|
protected class |
SelectorKernel.SelectorThread
This class is purposely tucked neatly away because
messing with the selector from other threads for any
reason is very bad.
|
EVENTS_PENDING
Constructor and Description |
---|
SelectorKernel(java.net.InetAddress host,
int port) |
SelectorKernel(java.net.InetSocketAddress address) |
SelectorKernel(int port) |
Modifier and Type | Method and Description |
---|---|
protected NioEndpoint |
addEndpoint(java.nio.channels.SocketChannel c) |
void |
broadcast(Filter<? super Endpoint> filter,
java.nio.ByteBuffer data,
boolean reliable,
boolean copy)
Dispatches the data to all endpoints managed by the
kernel that match the specified endpoint filter..
|
protected void |
closeEndpoint(NioEndpoint p)
Called by the endpoints when they need to be closed.
|
protected SelectorKernel.SelectorThread |
createSelectorThread() |
void |
initialize()
Initializes the kernel and starts any internal processing.
|
protected void |
newData(NioEndpoint p,
java.nio.channels.SocketChannel c,
java.nio.ByteBuffer shared,
int size) |
protected void |
removeEndpoint(NioEndpoint p,
java.nio.channels.SocketChannel c) |
void |
terminate()
Gracefully terminates the kernel and stops any internal
daemon processing.
|
protected void |
wakeupSelector()
Used internally by the endpoints to wakeup the selector
when they have data to send.
|
addEnvelope, addEvent, hasEnvelopes, nextEndpointId, nextEvent, read, reportError, wakeupReader
public SelectorKernel(java.net.InetAddress host, int port)
public SelectorKernel(int port) throws java.io.IOException
java.io.IOException
public SelectorKernel(java.net.InetSocketAddress address)
protected SelectorKernel.SelectorThread createSelectorThread()
public void initialize()
Kernel
public void terminate() throws java.lang.InterruptedException
Kernel
java.lang.InterruptedException
public void broadcast(Filter<? super Endpoint> filter, java.nio.ByteBuffer data, boolean reliable, boolean copy)
Kernel
protected NioEndpoint addEndpoint(java.nio.channels.SocketChannel c)
protected void removeEndpoint(NioEndpoint p, java.nio.channels.SocketChannel c)
protected void closeEndpoint(NioEndpoint p) throws java.io.IOException
java.io.IOException
protected void wakeupSelector()
protected void newData(NioEndpoint p, java.nio.channels.SocketChannel c, java.nio.ByteBuffer shared, int size)