On 1/16/07, Trustin Lee <[EMAIL PROTECTED]> wrote:
Hi Steven,

On 1/10/07, Steven E. Harris <[EMAIL PROTECTED]> wrote:
>
> I'm using a ProtocolEncoder and ProtocolDecoder pair supplied to a
> ProtocolCodecFilter, and am wondering whether the
> ProtocolEncoder.encode() and ProtocolDecoder.decode() methods will
> ever be called on concurrently for the same IoSession. That is, is it
> possible that an encoder is writing at the same time a decoder is
> reading?


Yes. (Related thread: *http://tinyurl.com/ygazu9)*

The question arises because the network protocol permits
> pipelining. The decoder side may see an error signaled by its peer,
> and wish to notify the encoder side to stop writing requests on this
> connection/session; hence the encoder and decoder communicate. Should
> I assume that this communication between encoder and decoder may be
> happening between separate threads, or can I assume that the encoder
> and decoder are never used concurrently, at least for a given
> IoSession?


IoSession.write() can be invoked from any thread, so you will need some kind
of inter-process communication in you IoHandler and writer thread.  I think

shouldn't that be "inter-thread communication" ?

Maarten

decoder is not a good place to detect a problem.  I'd rather use
exceptionCaught() handler.  You can filter exceptions from a decoder very
easily because all exceptions thrown by a decoder will be wrapped by
ProtocolDecoderException.

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