Re: threads::shared::share behaves differently when imported or not
[email protected] (Elizabeth Mattijsen)
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <p05111b14bb4d72387938@[192.168.2.108]> |
At 14:50 +0200 7/30/03, Stas Bekman wrote:
>if I 'use threads::shared', share() works as documented:
>
>perl-5.8.1-ithread -le 'use threads; use threads::shared; my $x;
>share($x); $x = 1;'
>
>perl-5.8.1-ithread -le 'use threads; use threads::shared; my $x;
>threads::shared::share($x); $x = 1;'
>
>However if I 'require threads::shared', it doesn't work the same way:
>
>perl-5.8.1-ithread -le 'use threads; require threads::shared; my $x;
>threads::shared::share($x); $x = 1;'
>Argument to share needs to be passed as ref at -e line 1.
>
>If I pass \$x it works.
>
>If I explicitly import share it doesn't.
>
>perl-5.8.1-ithread -le 'use threads; require threads::shared;
>threads::shared->import(qw(share)); my $x; share($x); $x = 1;'
>Argument to share needs to be passed as ref at -e line 1.
>
>why?
Maybe you're getting the dummy share sub somehow?
from threads::shared.pm
BEGIN {
if ($threads::threads) {
: yadayadayada
*cond_wait = \&cond_wait_enabled;
*cond_signal = \&cond_signal_enabled;
*cond_broadcast = \&cond_broadcast_enabled;
require XSLoader;
XSLoader::load('threads::shared',$VERSION);
push @EXPORT,'bless';
}
else {
*share = \&share_disabled;
*cond_wait = \&cond_wait_disabled;
*cond_signal = \&cond_signal_disabled;
*cond_broadcast = \&cond_broadcast_disabled;
}
}
: yadayadayada
sub share_disabled (\[$@%]) { return $_[0] }
Liz