au.com.terabit.jproactor
Class Demultiplexor

java.lang.Object
  extended by au.com.terabit.jproactor.Demultiplexor
All Implemented Interfaces:
java.lang.Runnable

public class Demultiplexor
extends java.lang.Object
implements java.lang.Runnable

The Demultiplexor class is the core engine of the JavaProactor.

Demultiplexor acts as IO processor and manages all IO operations requested by TCPAsynchChannel class. The IO oprations are proccessed asynchrously by the pool of threads using leader/follower pattern. Number of processing thread can be configured by start(int) operation.

Usually client applications does not require direct access to mutiplexor class, only when multiple protocols would like to reuse the same multiplexor instance.

Each multiplexor instance instantiates one Selector instance.

Version:
$Revision$ $Date$
Author:
Alexander Libman, Yevgeny Libman

Field Summary
static int dispatchStategy_
           
static int POOL_SIZE
          Default Thread Pool size
static int STRATEGY_BALANCE
           
static int STRATEGY_FAST
           
 
Constructor Summary
Demultiplexor()
          Creates multipliexor instance with default pool size.
 
Method Summary
 void declareInterest(TCPAsynchChannel achannel)
          Register m_asynchChannel.
 void run()
           
 void shutdown()
          Demultiplexor shutdown.
 void start()
          Start multiplexor using default thread pool size.
 void start(int poolSize)
          Start multiplexor.
 void startTimer(OpTimer timer)
          Schedules timer operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POOL_SIZE

public static final int POOL_SIZE
Default Thread Pool size

See Also:
Constant Field Values

STRATEGY_FAST

public static final int STRATEGY_FAST
See Also:
Constant Field Values

STRATEGY_BALANCE

public static final int STRATEGY_BALANCE
See Also:
Constant Field Values

dispatchStategy_

public static int dispatchStategy_
Constructor Detail

Demultiplexor

public Demultiplexor()
              throws java.io.IOException
Creates multipliexor instance with default pool size.

Throws:
java.io.IOException
Method Detail

start

public void start(int poolSize)
Start multiplexor.

Parameters:
poolSize - thread pool size

start

public void start()
Start multiplexor using default thread pool size.

See Also:
POOL_SIZE

run

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

declareInterest

public void declareInterest(TCPAsynchChannel achannel)
Register m_asynchChannel.


shutdown

public void shutdown()
              throws java.lang.InterruptedException
Demultiplexor shutdown. Stops all IO operations.

Throws:
java.lang.InterruptedException

startTimer

public void startTimer(OpTimer timer)
Schedules timer operation.

Parameters:
timer - operation