org.khelekore.rnio
Interface NioHandler

All Known Implementing Classes:
MultiSelectorNioHandler

public interface NioHandler

A handler of nio based events.


Method Summary
 void cancel(SelectableChannel channel, SocketChannelHandler handler)
          Remove an event listener.
 void close(SelectableChannel channel)
          Close the given channel.
 Long getDefaultTimeout()
          Get the default timeout time for an operations started at this point in time.
 StatisticsHolder getTimingStatistics()
          Get the timing information for the thread tasks.
 void runThreadTask(Runnable r, TaskIdentifier ti)
          Run a task in a background thread.
 void shutdown()
          Shutdown this task runner.
 void start()
          Start handling operations.
 void visitSelectors(SelectorVisitor visitor)
          Visit all the selectors.
 void waitForAccept(SelectableChannel channel, AcceptHandler handler)
          Install an event listener for accent events.
 void waitForConnect(SelectableChannel channel, ConnectHandler handler)
          Install an event listener for connect events.
 void waitForRead(SelectableChannel channel, ReadHandler handler)
          Install an event listener for read events.
 void waitForWrite(SelectableChannel channel, WriteHandler handler)
          Install an event listener for write events.
 

Method Detail

start

void start()
Start handling operations.


shutdown

void shutdown()
Shutdown this task runner. This will make the NioHandler stop accepting new thread tasks and it will close all channels that are still registerd (and call closed () for the channel handlers).


getDefaultTimeout

Long getDefaultTimeout()
Get the default timeout time for an operations started at this point in time.


runThreadTask

void runThreadTask(Runnable r,
                   TaskIdentifier ti)
Run a task in a background thread. The task will be run sometime in the future.

Parameters:
r - the task to run.

waitForRead

void waitForRead(SelectableChannel channel,
                 ReadHandler handler)
Install an event listener for read events. When the channels is ready the ReadHandler.read () method will be called and read selection will be turned off for the channel.


waitForWrite

void waitForWrite(SelectableChannel channel,
                  WriteHandler handler)
Install an event listener for write events. When the channel is ready the WriteHandler.write () method will be called and write selection will be turned off for the channel.


waitForAccept

void waitForAccept(SelectableChannel channel,
                   AcceptHandler handler)
Install an event listener for accent events. When the channel is ready the Accepthandler.accept () method will be called and accept selection will be turned off for the channel.


waitForConnect

void waitForConnect(SelectableChannel channel,
                    ConnectHandler handler)
Install an event listener for connect events. When the channel is ready the Connecthandler.connect () method will be called and connect selection will be turned off for the channel.


cancel

void cancel(SelectableChannel channel,
            SocketChannelHandler handler)
Remove an event listener.


close

void close(SelectableChannel channel)
Close the given channel. Closing a channel will cause SocketChannelHandler.close () to be raised on any listeners for this channel and will then cancel all selector interaction.


visitSelectors

void visitSelectors(SelectorVisitor visitor)
Visit all the selectors. This should really only be used for status handling and/or debugging.


getTimingStatistics

StatisticsHolder getTimingStatistics()
Get the timing information for the thread tasks.