in reply to Attempt to make shared Moose object
A few things:
To sum up:
use threads; use strict; { package ThreadableObj; use Moose; use threads::shared; use Data::Dumper; around 'new' => sub { my $orig = shift; my $class = shift; my $self = $class->$orig(@_); my $shared_self : shared = shared_clone($self); # here the blessed() already be the version in threads::shared print Dumper($shared_self),"\n"; return $shared_self; }; has foo => ( is => 'rw', isa => 'Str' ); has bar => ( is => 'rw', isa => 'Int' ); } # here lives my $obj : shared = ThreadableObj->new(foo=>'foovalue');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Attempt to make shared Moose object
by llancet (Friar) on Mar 02, 2010 at 02:05 UTC |