Hi Michael,

On 5/13/06, Michael Bauroth <[EMAIL PROTECTED]> wrote:

Hi,

at the moment there exist two basic possibilities to add a codec to a
chain. In one case there exists for every session one instance of the
decoder. In the other case I can return for the getDecoder() method in
the CodecFactory every time the same instance. At the moment I use the
second way.
My question now is, how can I handle that case, when I use instead of
SimpleByteBufferAllocator the normal ThreadPoolAllocator?
When I'm right, then I have now n parallel working threads with it's
separate own filterchain. Correct?
How can I now realize a behaviuour, that for each thread I have one own
decoder instance? Will each new working thread create it's own
filterchain with new instances of CodecFactory? Then would it mean, that
each of this factories creates it's own instance of the decoder, so all
  should be fine. Is this the case?
Do you know what I mean? :)


Actually I didn't get it.  Anyway... I'll explain what I know to you.

It's OK for you to create a new instance whenever getDecoder() or
getEncoder() is called.  It is called only once per session.  It shouldn't
affect the performance of your application at all.  If your protocol coded
is stateless or stores its state in IoSession's attributes, then you can
create a singleton and return it again and again.  But the implementation of
the codec can be complex.  It's completely up to you.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to