directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter royal <pro...@apache.org>
Subject Re: svn commit: r385254 - in /directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec: ProtocolCodecFactory.java ProtocolCodecFilter.java demux/DemuxingProtocolCodecFactory.java demux/MessageDecoderFactory.java demux/MessageEncoderFacto
Date Sun, 12 Mar 2006 23:48:34 GMT
On Mar 12, 2006, at 6:07 PM, Trustin Lee wrote:
> On 3/13/06, peter royal <proyal@apache.org> wrote:
> On Mar 12, 2006, at 1:08 AM, trustin@apache.org wrote:
> >       * Returns a new (or reusable) instance of {@link
> > ProtocolEncoder} which
> >       * encodes message objects into binary or protocol-specific  
> data.
> >       */
> > -    ProtocolEncoder getEncoder();
> > +    ProtocolEncoder getEncoder() throws Exception;
> >
> >      /**
> >       * Returns a new (or reusable) instance of {@link
> > ProtocolDecoder} which
> >       * decodes binary or protocol-specific data into message  
> objects.
> >       */
> > -    ProtocolDecoder getDecoder();
> > +    ProtocolDecoder getDecoder() throws Exception;
>
> Performance will suck if shared instances are returned due to
> synchronization on the returned instances in the
> ProtocolCodecFilter... Unless the synchronization is removed, it
> would be unadvisable to return shared instances.
>
> It depends on the implementation of codec.  Some codec might be  
> stateless so they don't need any synchronization.  Of course, a  
> codec factory usually returns a new instance.  It's a user's choice.

No, regardless of codec implementation...

http://svn.apache.org/viewcvs.cgi/directory/trunks/mina/core/src/main/ 
java/org/apache/mina/filter/codec/ProtocolCodecFilter.java? 
rev=385254&view=markup

look in messageReceived.. it synchronizes on decoder, prior to doing  
decoder.decode. So if you have a ProtocolDecoder that is stateless  
that could be shared, you will not be able to decode multiple  
messages in parallel.

-pete

-- 
proyal@apache.org - http://fotap.org/~osi



Mime
View raw message