in reply to Re: Re: Use thread with good care, but definitely keep using it
in thread Use thread with good care, but definitely keep using it

do you have any more information/links on this bless issue?


time was, I could move my arms like a bird and...
  • Comment on Re: Re: Re: Use thread with good care, but definitely keep using it

Replies are listed 'Best First'.
Re: Re: Re: Re: Use thread with good care, but definitely keep using it
by pg (Canon) on Mar 14, 2003 at 05:04 UTC
    The official doc is threads::shared, you can find info about this in the BUGS section.

    Whether there is any online article about this, I am not sure. You may give a search, if find any, please post links here, thanks.

    I created a short script to demo this, just uncomment either of the two commented lines. Compare the results from both cases. You will see that, if %hash itself is shared, you are not be able to assign $hash{VALUE} to an Object of Something correctly. Perl loses the object type, and simple coverts it into an unblessed hashref. Hence, you would not be able to call any method defined on that Object.
    use Something; use threads; use threads::shared; use strict; use warnings; #my %hash : shared; #my %hash; $hash{VALUE} = &share(new Something(1)); print $hash{VALUE}; package Something; sub new { shift; my $self = {}; $self->{VALUE} = shift; bless($self); return $self; } 1; 1;
      ouch!

      I thought I had read that before - but couldn't find it in perlthrtut, so just passed it off as a terrible fleeting delusion.


      time was, I could move my arms like a bird and...