develooper Front page | perl.perl5.porters | Postings from July 2002

Re: Thread::Use - use a module inside a thread only

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
July 30, 2002 02:59
Subject:
Re: Thread::Use - use a module inside a thread only
Message ID:
20020730105908.E38407@plum.flirble.org
On Tue, Jul 30, 2002 at 10:35:25AM +0200, Elizabeth Mattijsen wrote:
> At 09:36 AM 7/30/02 +0200, Rafael Garcia-Suarez wrote:
> > > Looks like stashes are not shared between threads. How
> > > is this related to saving memory ?
> 
>  > However, Thread::Use can also be handy for modules that do not survive
>  > the cloning process, such as PerlIO::gzip and many DBI::DBD modules...
> 
> Actually, the thing about PerlIO::gzip isn't true.  You can't create 
> threads with a PerlIO::gzip layer open currently.  Even if you don't need a 
> PerlIO::gzip layer in the thread.  There is no problem if you only want a 
> PerlIO::gzip layer inside a thread only.  So that is a different problem 
> altogether.

I haven't looked at this thoroughly (actually, it's only been 
cursory) but I think that cloning a layer open currently strictly requires
cloning zlib's struct. In turn, zlib's struct can contain dynamically
allocated structures, so they would have to be cloned too. Er, except
that zlib's struct is private to zlib. Conundrum.
I think deflateCopy() may actually be the solution, if it copies all parts
of a z_stream whether being for inflation or deflation.
But it would have to make the new copy using a malloc() that allocates memory
from the new thread, wouldn't it?

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About