in reply to Re: Testing if variable is threads::shared ?
in thread Testing if variable is threads::shared ?
Couple of things:
1) Any chance this will be exported into a public method someday ?
2) FYI: When I tried directly testing a ref operator (e.g., threads::shared::_id(\@ary)), it choked. I had to explicitly assign the ref to another variable, then it reports shared (which is the important bit for me).
For the record, here's a bit more complete test:
use threads; use threads::shared; package Dweeble; sub new { my $class = shift; my %obj : shared = ( cow => 'bossy' ); return bless \%obj, $class; } sub holycow { print "Holy Cow!\n"; } 1; package main; my $hope : shared = 27; my @ary : shared = (1,2,3,4,5); my $aryref = \@ary; my %hash : shared = ( one => 1, two => 2 ); my $hashref = \%hash; my $cow; my $krelboin = Dweeble->new(); print "hope is ", (threads::shared::_id($hope) ? "shared\n" : "private +\n"); print "cow is ", (threads::shared::_id($cow) ? "shared\n" : "private\n +"); print "ary is ", (threads::shared::_id($aryref) ? "shared\n" : "privat +e\n"); print "hash is ", (threads::shared::_id($hashref) ? "shared\n" : "priv +ate\n"); print "krelboin is ", (threads::shared::_id($krelboin) ? "shared\n" : +"private\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Testing if variable is threads::shared ?
by jdhedden (Deacon) on Aug 31, 2005 at 00:32 UTC |