Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Threads and shared blessed references (http://www.velocityreviews.com/forums/t886802-threads-and-shared-blessed-references.html)

Vetle Roeim 06-09-2004 01:55 PM

Threads and shared blessed references
 
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/groups?selm=200306091100.h59B05PA018110%40smtp3.Ac tiveState.com&output=gplain>

Umm... So I guess my question is: is it safe to share blessed references
among
threads? :)


--
Touch eyeballs to screen for cheap laser surgery!


All times are GMT. The time now is 02:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57