At 10:37 +0100 12/23/03, Leopold Toetsch wrote:
2) the Perl5ish declaration

my $var : shared;

is basically:

$P0 = new SharedPerlUndef;

OTOH:

share($var);

   may need to morph $var into a shared reference, with an additional
   indirection and memory overhead.

(I don't know, what Perl5 does with an already used "$var", that is
turned into a shared var later - or even at runtime).

$ perl5.8.2-threaded -Mthreads -Mthreads::shared -MO=Deparse -e 'my $a : shared = 1'
use attributes ();
('attributes'->import('main', \$a, 'shared'), my $a) = 1;


$ perl5.8.2-threaded -Mthreads -Mthreads::shared=share -MO=Deparse -e 'my $a = 1; share( $a )'
my $a = 1;
share $a;



Both the share() function as well as the ":shared" attribute, operate at runtime in Perl5. This is especially awkward for the ":shared" attribute.



I think your solution of making ":shared" to become a true compile time action, is best. If one wants to share at execution time, one can expect extra overhead.



So the overhead is only the necessary locking, the indirection can
easily be avoided.

I'm glad to hear that!



Liz

Reply via email to