You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Vinod Panicker <vi...@gmail.com> on 2005/04/04 08:29:21 UTC

[mina] sumup example question - thread pools

Hi,

Had a question regarding the impl of thread pools in the sumup example.

Basically in the client, I noticed this code - 

        IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
        ProtocolThreadPoolFilter protocolThreadPoolFilter = new
ProtocolThreadPoolFilter();

>From my understanding, both these filters are providing thread pools. 
Doesnt it make it unnecessary to use both these filters at the same
time?

Also, IoProtocolConnector is being used to establish the session with
the server.  That already has ProtocolHandler functionality.  Then why
the need for ProtocolThreadPoolFilter?

Regards,
Vinod.

Re: [mina] sumup example question - thread pools

Posted by Trustin Lee <tr...@gmail.com>.
Hi,

I'm sorry for a late reply.

On Apr 4, 2005 3:29 PM, Vinod Panicker <vi...@gmail.com> wrote:
> Hi,
> 
> Had a question regarding the impl of thread pools in the sumup example.
> 
> Basically in the client, I noticed this code -
> 
>        IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
>        ProtocolThreadPoolFilter protocolThreadPoolFilter = new
> ProtocolThreadPoolFilter();
> 
> From my understanding, both these filters are providing thread pools.
> Doesnt it make it unnecessary to use both these filters at the same
> time?

Protocol layer works upon I/O layer.  So, decoding and encoding occurs
in I/O thread pool and protocol events are fired from I/O thread pool
thread.  And then ProtocolHandler received events.  If you add
ProtocolThreadPoolFilter, then events are passed to protocol thread
pool filter and forwarded at a different thread.  This is because
ProtocolHandler will contain more complex business logic.  Codecs
usually consume CPU mostly, but I suspect ProtocolHandler will perform
different kind of operations such as disk I/O, DB access, etc.  If
your protocol handler implementation is CPU intensive, you'll be able
to use thread pool filter only at I/O layer.

Regards,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/