You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Giacomo Pati <Gi...@pwr.ch> on 2000/07/24 21:09:04 UTC

More C2 thread savety issues

Hi all

I'm trying to think about a thread save Transformer component. But I
think with the current API it is impossible.

What happens during pipeline processing today is something similar to
this (example totally shortened):

    serializer.setOutputStream (out);
    transformer.setConsumer (serializer);
   generator.setConsumer (transformer);
    generator.generate();

The setConsumer method makes the transformer need to save the consumer
in a variable at class level. IMHO this prevents the transformer to be
thread save. Right, or am I stupid?

The same I think applies to the generator (setConsumer) and the
serializer (setOutputStream) as well.

I have no solution to this and Stefano stated in an earier mail that
sitemap components must be thread save. But the current API must be
changed dramatically () to allow this or sitemap components still have
to be instantiated for every single request or the sitemap component
itself instantiates some other component to achieve thread savetyness to
the sitemap. Does anybody has a good idea?

Giacomo
-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

Re: More C2 thread savety issues

Posted by Paul Russell <pa...@luminas.co.uk>.
On Mon, Jul 24, 2000 at 10:33:20PM +0200, Giacomo Pati wrote:
> In fact they are all non-threadsafe because of the api, right
> (at least generators, transformers and serializers) ?

Yep, because there is no context passed to the SAX api
functions, and because the order of the calls is significant,
classes utilising the SAX api can never be inherently thread
safe. You could synchronize on the component before starting
to use it, which would stop anyone else interfering with it
until you'd finished, but this will hold up the pipelines.
Once we've got pooling into Avalon, things should be a lot
friendlier and quicker.


Paul

-- 
Paul Russell                               <pa...@luminas.co.uk>
Technical Director,                   http://www.luminas.co.uk
Luminas Ltd.

Re: More C2 thread savety issues

Posted by Giacomo Pati <Gi...@pwr.ch>.
On Mon, Jul 24, 2000 at 03:34:26PM -0400, Donald Ball wrote:
> On Mon, 24 Jul 2000, Giacomo Pati wrote:
> 
> > I have no solution to this and Stefano stated in an earier mail that
> > sitemap components must be thread save. But the current API must be
> > changed dramatically () to allow this or sitemap components still have
> > to be instantiated for every single request or the sitemap component
> > itself instantiates some other component to achieve thread savetyness to
> > the sitemap. Does anybody has a good idea?
> 
> allow components to be non-threadsafe - do create and destroy on them
> right now but pool them later when stefano gets his pooling code into
> avalon.

In fact they are all non-threadsafe because of the api, right (at least generators, transformers and serializers) ?

Giacomo

> 
> - donald
> 

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch


Re: More C2 thread savety issues

Posted by Giacomo Pati <Gi...@pwr.ch>.
On Mon, Jul 24, 2000 at 03:34:26PM -0400, Donald Ball wrote:
> On Mon, 24 Jul 2000, Giacomo Pati wrote:
> 
> > I have no solution to this and Stefano stated in an earier mail that
> > sitemap components must be thread save. But the current API must be
> > changed dramatically () to allow this or sitemap components still have
> > to be instantiated for every single request or the sitemap component
> > itself instantiates some other component to achieve thread savetyness to
> > the sitemap. Does anybody has a good idea?
> 
> allow components to be non-threadsafe - do create and destroy on them
> right now but pool them later when stefano gets his pooling code into
> avalon.

In fact, I was looking for some better alternative to make some of the component being able to be thread save. You propose the way it is, and this gets no chance of getting thread save anyway.

Giacomo 

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch


Re: More C2 thread savety issues

Posted by Donald Ball <ba...@webslingerZ.com>.
On Mon, 24 Jul 2000, Giacomo Pati wrote:

> I have no solution to this and Stefano stated in an earier mail that
> sitemap components must be thread save. But the current API must be
> changed dramatically () to allow this or sitemap components still have
> to be instantiated for every single request or the sitemap component
> itself instantiates some other component to achieve thread savetyness to
> the sitemap. Does anybody has a good idea?

allow components to be non-threadsafe - do create and destroy on them
right now but pool them later when stefano gets his pooling code into
avalon.

- donald