Hi,

I also think that most Encoders/Decoders will be thread-safe so that it should be possible to remove the synchronized-Blocks at the calling places. Perhaps it would be helpful to have something similar like the Collections.synchronizedXXX(...) methods for Encoders/Decoders.

public class NotThreadSafeCodecFactory implements ProtocolCodecFactory
{
   private final ProtocolEncoder encoder;
   private final ProtocolEncoder decoder;
public NotThreadSafeCodecFactory()
   {
encoder = ProtocolCodec.synchronizedEncoder(new NotThreadSafeEncoder()); decoder = ProtocolCodec.synchronizedDecoder(new NotThreadSafeDecoder());
   }
...

Using this pattern the explicit synchronization at the Codec-Calls can be removed. One can even mix thread-safe encoders with non-thread-safe decoders or vice versa.

Mike

Trustin Lee wrote:
Hi,

Peter and I once talked about removing synchronization on a ProtocolEncoder
and a ProtocolDecoder.  This synchronization block is a cause of performance
degradation when a user wants to share one encoder/decoder instance between
multiple sessions.  I think some decoders and almost all encoders can be
shared safely.

Any idea?

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

------------------------------------------------------------------------

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.1/292 - Release Date: 24.03.2006

Reply via email to