5.10 threads :: shared message

5.10 threads :: shared message

am 20.12.2007 17:00:44 von Ancient_Hacker

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???

Re: 5.10 threads :: shared message

am 20.12.2007 17:07:14 von Joost Diepenmaat

Abble 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.

Re: 5.10 threads :: shared message

am 20.12.2007 17:57:57 von Ancient_Hacker

On Dec 20, 10:07 am, Joost Diepenmaat wrote:
> Abble 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!

Re: 5.10 threads :: shared message

am 20.12.2007 19:07:33 von Ben Morrow

Quoth Abble :
> 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

Re: 5.10 threads :: shared message

am 20.12.2007 22:40:39 von Ben Morrow

Quoth Ben Morrow :
> Quoth Abble :
> > I get:
> >
> > "Bizarre copy of HASH in aassign at DiskSpeeds.pl line 10."
> >
> > when I do:

>
> 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

Re: 5.10 threads :: shared message

am 22.12.2007 13:51:10 von zentara

On Thu, 20 Dec 2007 08:00:44 -0800 (PST), Abble
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