|
The Meta-Environment API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttoolbus.communication.SocketWriteMultiplexer
public class SocketWriteMultiplexer
This class handles the multiplexing of socket channels that we are registered for write operations.
Field Summary | |
---|---|
private AbstractConnectionHandler |
connectionHandler
|
private boolean |
running
|
private toolbus.util.concurrency.Latch |
selectionPreventionLatch
|
private java.nio.channels.Selector |
selector
|
Constructor Summary | |
---|---|
SocketWriteMultiplexer(AbstractConnectionHandler connectionHandler)
Constructor. |
Method Summary | |
---|---|
void |
deregisterForWrite(java.nio.channels.SelectableChannel channel)
Deregisters the given channel for writing (if nessecary). |
boolean |
isRunning()
Checks if this multiplexer is running or not. |
void |
registerForWrite(java.nio.channels.SelectableChannel channel,
SocketIOHandler ioHandler)
Registers the given channel for writing. |
void |
run()
The main loop of this multiplexer. |
void |
stopRunning()
Stops the execution of this multiplexer after then next iteration. |
private void |
write(java.nio.channels.SelectionKey key)
Notifies the with the selection key associated I/O handler that we are able to send data. |
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 SocketWriteMultiplexer(AbstractConnectionHandler connectionHandler)
connectionHandler
- The connection handler this write multiplexer was created by.Method Detail |
---|
public boolean isRunning()
public void stopRunning()
public void run()
run
in interface java.lang.Runnable
private void write(java.nio.channels.SelectionKey key)
key
- The key associated with the channel that we can write to.public void registerForWrite(java.nio.channels.SelectableChannel channel, SocketIOHandler ioHandler)
IWriteMultiplexer
registerForWrite
in interface IWriteMultiplexer
channel
- The channel that needs to be registered for writing.ioHandler
- The I/O handler that is associated with the given channelIWriteMultiplexer.registerForWrite(SelectableChannel, SocketIOHandler)
public void deregisterForWrite(java.nio.channels.SelectableChannel channel)
IWriteMultiplexer
deregisterForWrite
in interface IWriteMultiplexer
channel
- The channel that needs to be deregistered for writing.IWriteMultiplexer.deregisterForWrite(SelectableChannel)
|
The Meta-Environment API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |