Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   5.10 threads :: shared message (http://www.velocityreviews.com/forums/t905810-5-10-threads-shared-message.html)

Abble 12-20-2007 04:00 PM

5.10 threads :: shared message
 
I get:

"Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."


when I do:

use strict; use English; use warnings;
use Time::HiRes;
use threads;
use threads :: shared;
use Net::Ping;


my( %Times, %Samples, %Time, %Avg ) : shared = 1; ## line 10


my( @Vols, $Begins );


Any ideas???




Joost Diepenmaat 12-20-2007 04:07 PM

Re: 5.10 threads :: shared message
 
Abble <grg2@comcast.net> writes:

> I get:
>
> "Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."


Why are you assigning 1 to a list of hashes?

my( %Times, %Samples, %Time, %Avg ) : shared;

Doesn't give the error. I haven't checked if you can actually assign
attributes this way, though.

Joost.

Abble 12-20-2007 04:57 PM

Re: 5.10 threads :: shared message
 
On Dec 20, 10:07 am, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> Abble <g...@comcast.net> writes:
> > I get:

>
> > "Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."

>
> Why are you assigning 1 to a list of hashes?
>
> my( %Times, %Samples, %Time, %Avg ) : shared;
>
> Doesn't give the error. I haven't checked if you can actually assign
> attributes this way, though.
>
> Joost.


Oh, the example I saw had the shared = 1 bizness; Will try it
without.


Thanks!



Ben Morrow 12-20-2007 06:07 PM

Re: 5.10 threads :: shared message
 

Quoth Abble <grg2@comcast.net>:
> I get:
>
> "Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."
>
> when I do:
>
> use strict; use English; use warnings;
> use Time::HiRes;
> use threads;
> use threads :: shared;
> use Net::Ping;
>
>
> my( %Times, %Samples, %Time, %Avg ) : shared = 1; ## line 10
>
>
> my( @Vols, $Begins );


Bug in threads::shared. A simpler example is

use threads;
use threads::shared;

my ($x, @y) :shared = (1);

This also existed in 5.8.8, it isn't new in 5.10. The threads::shared
implementation of shared arrays and shared hashes is an evil stinking
mess, made necessary by the fact that perl's magic system isn't really
OO, it just kinda looks that way if you don't look too closely :).

Ben


Ben Morrow 12-20-2007 09:40 PM

Re: 5.10 threads :: shared message
 

Quoth Ben Morrow <ben@morrow.me.uk>:
> Quoth Abble <grg2@comcast.net>:
> > I get:
> >
> > "Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."
> >
> > when I do:

<snip>
>
> Bug in threads::shared. A simpler example is
>
> use threads;
> use threads::shared;
>
> my ($x, @y) :shared = (1);


Having looked into this further: the bug isn't in threads::shared, it's
in the attribute-handling code. Although this

use Attribute::Handlers;

sub Foo : ATTR {
warn "Applying :$_[3]";
}

my ($x, @y) :Foo = (1);

doesn't give an error with 5.8.8, it does with 5.10.0; and in both cases
it fails to set $x. I've reported this to p5p...

Ben


zentara 12-22-2007 12:51 PM

Re: 5.10 threads :: shared message
 
On Thu, 20 Dec 2007 08:00:44 -0800 (PST), Abble <grg2@comcast.net>
wrote:

>
> my( %Times, %Samples, %Time, %Avg ) : shared = 1; ## line 10


>Any ideas???


Besides the other advice given, when you share hashes, only the top
level keys get shared. So don't expect a deep hash to be completely
shared unless you explicitly share the deeper keys.

zentara

--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


All times are GMT. The time now is 01:31 PM.

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