|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.core.service.SimpleIoProcessorPool<T>
T - the type of the IoSession to be managed by the specified
IoProcessor.public class SimpleIoProcessorPool<T extends AbstractIoSession>
An IoProcessor pool that distributes IoSessions into one or more
IoProcessors. 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 IoServices in the
same JVM.
If you are running multiple IoServices, 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:
ExecutorService parameter.Executor parameter.
// 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();
| Constructor Summary | |
|---|---|
SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType)
|
|
SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType,
Executor executor)
|
|
SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType,
Executor executor,
int size)
|
|
SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType,
int size)
|
|
| Method Summary | |
|---|---|
void |
add(T session)
Adds the specified session to the I/O processor so that
the I/O processor starts to perform any I/O operations related
with the session. |
void |
dispose()
Releases any resources allocated by this processor. |
void |
flush(T session)
Flushes the internal write request queue of the specified session. |
boolean |
isDisposed()
Returns true if and if only all resources of this processor have been disposed. |
boolean |
isDisposing()
Returns true if and if only IoProcessor.dispose() method has
been called. |
void |
remove(T session)
Removes and closes the specified session from the I/O
processor so that the I/O processor closes the connection
associated with the session and releases any other related
resources. |
void |
updateTrafficMask(T session)
Controls the traffic of the specified session as specified
in IoSession.getTrafficMask(). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType)
public SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType,
int size)
public SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType,
Executor executor)
public SimpleIoProcessorPool(Class<? extends IoProcessor<T>> processorType,
Executor executor,
int size)
| Method Detail |
|---|
public final void add(T session)
IoProcessorsession to the I/O processor so that
the I/O processor starts to perform any I/O operations related
with the session.
add in interface IoProcessor<T extends AbstractIoSession>public final void flush(T session)
IoProcessorsession.
flush in interface IoProcessor<T extends AbstractIoSession>public final void remove(T session)
IoProcessorsession from the I/O
processor so that the I/O processor closes the connection
associated with the session and releases any other related
resources.
remove in interface IoProcessor<T extends AbstractIoSession>public final void updateTrafficMask(T session)
IoProcessorsession as specified
in IoSession.getTrafficMask().
updateTrafficMask in interface IoProcessor<T extends AbstractIoSession>public boolean isDisposed()
IoProcessor
isDisposed in interface IoProcessor<T extends AbstractIoSession>public boolean isDisposing()
IoProcessorIoProcessor.dispose() method has
been called. Please note that this method will return true
even after all the related resources are released.
isDisposing in interface IoProcessor<T extends AbstractIoSession>public final void dispose()
IoProcessor
dispose in interface IoProcessor<T extends AbstractIoSession>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||