cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@s-und-n.de>
Subject RE: ContentAggregator and multithreating (migrating C2 -> C2.1M2), is it thread-safe?
Date Fri, 23 May 2003 14:34:08 GMT
Christoph Gaffga wrote:
> Just to see if I got it right, you wrote:
> > Have a look at the DefaultIncludeCacheManager - it can include in
> parallel.
> 
> my Aggregator does:
> 
>     // Part extends Thread
>     Part.run() {
>       SourceUtil.toSAX(part.source, buffer);
>     }
> 
>     // Aggregator.generate()
>     for(iterate all parts) {
>       part.start();
>     }
>     for(iterate all parts) {
>       part.join();
>       part.buffer.toSAX(contentHandler);
>     }
> 
> so I need to do something like:
> 
>     // Aggregator.generate()
>     for(iterate all parts) {
>       part.includeCacheManager = new DefaultIncludeCacheManager();
>       part.includeCacheManager.compose(this.manager);
>       part.session = includeCacheManager.getSession(this.par);
>       part.includeCacheManager.load(part.uri, part.session);
>     }
>     for(iterate all parts) {
>       part.includeCacheManager.stream(part.uri, part.session,
> contentHandler);
>     }
> 
> Is this right? Please give me a hint because I am not so familar 
> whith these
> IncludeCacheManager(and Session)-stuff.
Basically, yes. You have to turn on the parallel processing setting
a parameter (it's documented) when calling getSession(Parameter).


> P.S.:
> is there a special reason you are using
>     // wait
>     while (!loader.finished) {
>       try {
>         Thread.sleep(10);
>       } catch (InterruptedException e) { }
>     }
> in DefaultIncludeCacheManger (line 259). Isn't it better to have 
> the thread
> as a class variable (see line 212) and then use thread.join()?
> 
Hmmm, actually I don't know why this has been done in that way.
Perhaps join() is better.

Carsten

Mime
View raw message