fabric.net
Class ChannelMultiplexerThread

java.lang.Object
  extended by java.lang.Thread
      extended by fabric.net.ChannelMultiplexerThread
All Implemented Interfaces:
java.lang.Runnable

public final class ChannelMultiplexerThread
extends java.lang.Thread

Multiplexes several channels over a single channel.


Nested Class Summary
static interface ChannelMultiplexerThread.CallbackHandler
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int BUFFER_SIZE
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ChannelMultiplexerThread(ChannelMultiplexerThread.CallbackHandler handler, java.lang.String name, java.nio.channels.SocketChannel socketChannel)
          Creates a new thread that will multiplex/demultiplex multiple streams over the given socket channel.
 
Method Summary
 void registerChannels(int streamID, java.nio.channels.Pipe.SourceChannel source, java.nio.channels.Pipe.SinkChannel sink)
          Registers a pair of channels for communicating with a message-handler thread, assigning them a designated streamID, and registers the source channel with the selector.
 int registerChannels(java.nio.channels.Pipe.SourceChannel source, java.nio.channels.Pipe.SinkChannel sink)
          Registers a pair of channels for communicating with a message-handler thread, assigning them a fresh streamID, and registers the source channel with the selector.
 void run()
           
 void shutdown()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

ChannelMultiplexerThread

public ChannelMultiplexerThread(ChannelMultiplexerThread.CallbackHandler handler,
                                java.lang.String name,
                                java.nio.channels.SocketChannel socketChannel)
                         throws java.io.IOException
Creates a new thread that will multiplex/demultiplex multiple streams over the given socket channel.

Parameters:
handler - a handler for callbacks.
name - the name of the thread.
socketChannel - the socket channel to use.
Throws:
java.io.IOException
Method Detail

shutdown

public void shutdown()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

registerChannels

public void registerChannels(int streamID,
                             java.nio.channels.Pipe.SourceChannel source,
                             java.nio.channels.Pipe.SinkChannel sink)
                      throws java.io.IOException
Registers a pair of channels for communicating with a message-handler thread, assigning them a designated streamID, and registers the source channel with the selector.

Throws:
java.io.IOException

registerChannels

public int registerChannels(java.nio.channels.Pipe.SourceChannel source,
                            java.nio.channels.Pipe.SinkChannel sink)
                     throws java.io.IOException
Registers a pair of channels for communicating with a message-handler thread, assigning them a fresh streamID, and registers the source channel with the selector.

Throws:
java.io.IOException