llancet has asked for the wisdom of the Perl Monks concerning the following question:
However, the constructed object is not shared, as shows in this error message:use strict; use threads; use threads::shared; { package ThreadableObj; use Moose; use threads::shared; use Data::Dump qw/dump/; sub BUILD { my $self = shift; # here the blessed() already be the version in threads::shared bless shared_clone($self), ref($self); print dump($self),"\n"; return $self; } has foo => ( is => 'rw', isa => 'Str' ); has bar => ( is => 'rw', isa => 'Int' ) } # here dies my $obj : shared = ThreadableObj->new(foo=>'foovalue');
Moreover, the output of dump() is:Invalid value for shared scalar at XXXXX
Any suggestions? Thanks a lot!bless({ bar => 123, foo => "foovalue" }, "ThreadableObj")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Attempt to make shared Moose object
by tigre (Acolyte) on Mar 01, 2010 at 19:41 UTC | |
by llancet (Friar) on Mar 02, 2010 at 02:05 UTC |