org.khelekore.rnio.impl
Class SocketHandlerBase<T extends SelectableChannel>

java.lang.Object
  extended by org.khelekore.rnio.impl.SocketHandlerBase<T>
All Implemented Interfaces:
SocketChannelHandler
Direct Known Subclasses:
Acceptor, SimpleBlockReader, SimpleBlockSender

public abstract class SocketHandlerBase<T extends SelectableChannel>
extends Object
implements SocketChannelHandler

A socket handler that never times out and always runs on the selector thread.

Author:
Robert Olofsson

Field Summary
 NioHandler nioHandler
           
 T sc
           
 Long timeout
           
 
Constructor Summary
SocketHandlerBase(T sc, NioHandler nioHandler, Long timeout)
           
 
Method Summary
 void closed()
          Signal that the channel has been closed.
 String getDescription()
          Returns the class name.
 Long getTimeout()
          Will return null to indicate no timeout on accepts.
 void timeout()
          Handle timeouts.
 boolean useSeparateThread()
          Will always run on the selector thread so return false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sc

public final T extends SelectableChannel sc

nioHandler

public final NioHandler nioHandler

timeout

public final Long timeout
Constructor Detail

SocketHandlerBase

public SocketHandlerBase(T sc,
                         NioHandler nioHandler,
                         Long timeout)
Parameters:
sc - the channel to handle
nioHandler - the NioHandler
timeout - the timeout in millis, may be null if no timeout is wanted.
Method Detail

getTimeout

public Long getTimeout()
Will return null to indicate no timeout on accepts.

Specified by:
getTimeout in interface SocketChannelHandler
Returns:
the time when this operation times out, null if no timeout is set.

getDescription

public String getDescription()
Returns the class name.

Specified by:
getDescription in interface SocketChannelHandler

useSeparateThread

public boolean useSeparateThread()
Will always run on the selector thread so return false.

Specified by:
useSeparateThread in interface SocketChannelHandler
Returns:
false

timeout

public void timeout()
Handle timeouts. Default implementation just calls closed().

Specified by:
timeout in interface SocketChannelHandler

closed

public void closed()
Description copied from interface: SocketChannelHandler
Signal that the channel has been closed.

Specified by:
closed in interface SocketChannelHandler