V
Vetle Roeim
Quote from threads::shared (Perl 5.8.3):
"bless" is not supported on shared references. In the current version,
"bless" will only bless the thread local reference and the blessing
will not
propagate to the other threads.
In other words, it's not possible to share references to objects. I.e.
the
following shouldn't work:
package Foo::Bar;
use threads;
use threads::shared;
sub new { my $self = &share( {} ); bless $self, shift; }
sub zot { print "zot\n"; }
my $foo = Foo::Bar->new;
threads->create( sub {
$foo->zot;
}
)->join;
Is that a correct interpretation? Because the code example does actually
work
without any problems.
I also found a mail that indicates that blessing of sharede references
should
indeed work:
<URL:http://groups.google.com/[email protected]&output=gplain>
Umm... So I guess my question is: is it safe to share blessed references
among
threads?
"bless" is not supported on shared references. In the current version,
"bless" will only bless the thread local reference and the blessing
will not
propagate to the other threads.
In other words, it's not possible to share references to objects. I.e.
the
following shouldn't work:
package Foo::Bar;
use threads;
use threads::shared;
sub new { my $self = &share( {} ); bless $self, shift; }
sub zot { print "zot\n"; }
my $foo = Foo::Bar->new;
threads->create( sub {
$foo->zot;
}
)->join;
Is that a correct interpretation? Because the code example does actually
work
without any problems.
I also found a mail that indicates that blessing of sharede references
should
indeed work:
<URL:http://groups.google.com/[email protected]&output=gplain>
Umm... So I guess my question is: is it safe to share blessed references
among
threads?