|
The Meta-Environment API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttoolbus.communication.SocketReadMultiplexer
public class SocketReadMultiplexer
This class handles the multiplexing of socket channels that we are registered for read operations.
| Field Summary | |
|---|---|
private AbstractConnectionHandler |
connectionHandler
|
private boolean |
running
|
private toolbus.util.concurrency.Latch |
selectionPreventionLatch
|
private java.nio.channels.Selector |
selector
|
| Constructor Summary | |
|---|---|
SocketReadMultiplexer(AbstractConnectionHandler connectionHandler)
Constructor. |
|
| Method Summary | |
|---|---|
void |
deregisterForRead(java.nio.channels.SelectableChannel channel)
Deregisters the given channel for reading (if nessecary). |
boolean |
isRunning()
Checks if this multiplexer is running or not. |
private void |
read(java.nio.channels.SelectionKey key)
Notifies the with the selection key associated I/O handler that we are able to receive data. |
void |
registerForRead(java.nio.channels.SelectableChannel channel,
SocketIOHandler ioHandler)
Registers the given channel for reading. |
void |
run()
The main loop of this multiplexer. |
void |
stopRunning()
Stops the execution of this multiplexer after then next iteration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final toolbus.util.concurrency.Latch selectionPreventionLatch
private final AbstractConnectionHandler connectionHandler
private final java.nio.channels.Selector selector
private volatile boolean running
| Constructor Detail |
|---|
public SocketReadMultiplexer(AbstractConnectionHandler connectionHandler)
connectionHandler - The connection handler this read multiplexer was created by.| Method Detail |
|---|
public boolean isRunning()
public void stopRunning()
public void run()
run in interface java.lang.Runnableprivate void read(java.nio.channels.SelectionKey key)
key - The key associated with the channel that we can read from.
public void registerForRead(java.nio.channels.SelectableChannel channel,
SocketIOHandler ioHandler)
IReadMultiplexer
registerForRead in interface IReadMultiplexerchannel - The channel that needs to be registered for reading.ioHandler - The I/O handler that is associated with the given channel.IReadMultiplexer.registerForRead(SelectableChannel, SocketIOHandler)public void deregisterForRead(java.nio.channels.SelectableChannel channel)
IReadMultiplexer
deregisterForRead in interface IReadMultiplexerchannel - The channel that needs to be deregistered for reading.IReadMultiplexer.deregisterForRead(SelectableChannel)
|
The Meta-Environment API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||