[sorry, I forgot to Cc: the list.  resending.]

Jeremy White wrote:
> 
>> Jeremy, Eric,
>>
>> Thanks for your replies.  Actually, I was able to get an answer a month
>> ago, on perl5-porters.  A discussion ensued, and I had a few other
>> issues to resolve (such as perl 5.8.7 not allowing me to SvSHARE() a
>> code reference).
> 
> 
> No worries:) I must have missed your original post.
> 
> While we're on the subject of SvSHARE, have you any pointers to
> documentation to show how it's used?

threads::shared(3pm).


> The API docs simply say  "Arranges for sv to be shared between threads
> if a suitable module has been loaded.", which leads to a lot of
> questions. For example: What can and can not be shared? If a hash is
> shared, are sv's added to the hash shared too? Does Perl maintain the
> mutex locks on a shared SV, or do we have to do it explicitly with
> SvLock? I can think of a few more questions as well:)

The "suitable module" they were talking about is threads::shared.  It
seems SvSHARE and SvLOCK are the XS entry points to threads::shared's
share() and lock() functions.  The perl script needs to have done a "use
threads; use threads::shared" before these functions are usable.

At the moment, it looks from the manpage like most normal data
structures are share()able, though I wouldn't assume share() works more
than one level of references deep.

However, this error message seems to indicate that they plan to add the
ability to share() more things:

$ perl -Mthreads -Mthreads::shared -e 'sub s {}; my $s=\&s; share($s);'
Cannot share subs yet at -e line 1.

I'm hoping they do; sharing sub refs (esp. closures!) would be really
*really* useful for Fuse.

Mark

Reply via email to