| An
IoProcessor pool that distributes
IoSession s into one or more
IoProcessor s. Most current transport implementations use this pool internally
to perform better in a multi-core environment, and therefore, you won't need to
use this pool directly unless you are running multiple
IoService s in the
same JVM.
If you are running multiple
IoService s, you could want to share the pool
among all services. To do so, you can create a new
SimpleIoProcessorPool instance by yourself and provide the pool as a constructor parameter when you
create the services.
This pool uses Java reflection API to create multiple
IoProcessor instances.
It tries to instantiate the processor in the following order:
- A public constructor with one
ExecutorService parameter.
- A public constructor with one
Executor parameter.
- A public default constructor
The following is an example for the NIO socket transport:
// Create a shared pool.
SimpleIoProcessorPool<NioSession> pool =
new SimpleIoProcessorPool<NioSession>(NioProcessor.class, 16);
// Create two services that share the same pool.
SocketAcceptor acceptor = new NioSocketAcceptor(pool);
SocketConnector connector = new NioSocketConnector(pool);
...
// Release related resources.
connector.dispose();
acceptor.dispose();
pool.dispose();
author: The Apache MINA Project (dev@mina.apache.org) version: $Rev: 609876 $, $Date: 2008-01-07 22:40:38 -0700 (Mon, 07 Jan 2008) $< Parameters: T - > the type of the IoSession to be managed by the specifiedIoProcessor. |