TOD has asked for the wisdom of the Perl Monks concerning the following question:
what is confusing me here is that the manpage for threads::shared says: "C<share> will traverse up references exactly I<one> level. C<share(\$a)> is equivalent to C<share($a)>, while C<share(\\$a)> is not. This means that you must create nested shared data structures by first creating individual shared leaf notes, then adding them to a shared hash or array." does this mean, that in my example the $data value form %el has to be explicitly shared as well, or will it become shared automatically, since it's a scalar value and part of %el?our %planets : shared; our $response = SomeClass::TCP_IP_Response->new(@some_arguments); [...] lock %planets; if (exists $planets{$some_id}) { lock $planets{$some_id}; $response->content($planets{$some_id}->{'data'}); $planets{$some_id}->{'atime'} = time; } else { my $data; [...] # read the serialized data from disk my %el = ( 'data' => $data, 'atime' => time, 'deleted' => 0, 'modified' => 0 ); $planets{$some_id} = share(%el); }
|
|---|