Hello,

It's a little confusing.

If you take a look at the code for the NioSocketAcceptor, it just passes the 
NioProcessor and executor up to its superclass AbstractPollingIoAcceptor.  This 
takes the NioProcessor as given and stores it away (or instantiates one if you 
use the constructor not specifying an IoProcessor).  The Executor is passed to 
the superconstructor for AbstractIoAcceptor, which in turns  passes it to its 
superconstructor AbstractIoService.  The only time this is used is in the 
executeWorker().  This method is used by the AbstractIoAcceptor to startup the 
Acceptor Thread.

So in short, the executor you pass in is used to create the acceptor thread.  
The processor you pass in will still use the executor you pass in when you 
instantiated it.

The other constructor signatures...

NioSocketAcceptor() --> Creates a cached thread pool for the AcceptorThread 
executor, and creates a new NioProcessor with ProcessorCount+1 threads from a 
separate cached thread pool.
NioSocketAcceptor(int processorCount)  --> Same as above but you can override 
how many NioProcessor threads are created.
NioSocketAcceptor(IoProcessor<NioSession> processor) -->  Specify the 
IoProcessor, but it will still use a separately created cached thread pool to 
create the acceptor thread.

Digging through the code gives some interesting insight into how Mina works and 
why it is suggested that you use cached thread pools for the Acceptor and 
IoProcessor executors.  They don't really use the executor to do their work, 
they just use the executor to create a thread and then it sticks around for a 
long time.  Kind of an odd use of an executor, since you think you'd just use a 
ThreadFactory if you're looking for thread creation.

Chris



________________________________
From: "Simmons, Aaron" <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Mon, January 4, 2010 10:57:49 AM
Subject: RE: thread naming

I tried the same things you tried-- but I wanted to ask just in case there was 
something I was missing.  :)

As for the ExecutorFilter method-- I'm somewhat unclear of the relationship to 
the Executor used inside NioProcessor and the Executor(s) you can set through 
the Filter Chain.  Does the ExecutorFilter replace the use of the Executor used 
by NioProcessor?



      

Reply via email to