It is only my own experience, but here is my way to set
Thread Pool for several part of Mina in 1.0 :

For SocketAcceptor (or IoAcceptor) :
    Executor executor1 = Executors.newFixedThreadPool(nbThread);
    SocketAcceptor acceptor = new SocketAcceptor(nbThread, executor1);

My feeling is that it shouldn't be a newCachedThreadPool here since
it seems it is relative to the number of SocketIoProcessors that
the SocketAcceptor will use.
By default (new SocketAcceptor() without arguments), it use
a value of 16 threads and SocketIoProcessors.

For SocketAcceptorConfig (or IoAcceptorConfig), in order to
be able to specify my own Thread Pool Filter:
    SockectAccaptorConfig config = new SocketAcceptorConfig();
    config.setThreadModel(ThreadModel.MANUAL);

Then for the filter chain (example here is for compression) :
    IoFilterChain chain = config.getFilterChain();

    Executor executor2 = Executors.newCachedThreadPool();
    chain.addLast( "compressionPool",
        new ExecutorFilter( new ExecutorExecutor( executor2 ) ) );
    chain.addLast( "compression", compressionFilter);

And so on for any Filters that could be expensive in cpu...

    chain.addLast( "otherPool",
        new ExecutorFilter( new ExecutorExecutor( 
            Executors.newCachedThreadPool() ) ) );
    chain.addLast( "other", other);

You can use also newFixedThreadPool instead of 
newCachedThreadPool as you want here for FilterChain.

Hope this helps you.
Frederic

Reply via email to