our @EXPORT = qw(share cond_wait cond_broadcast cond_signal _refcnt _id _thrcnt);
our $VERSION = '0.90';
-use Attribute::Handlers;
-
-
if ($Config{'useithreads'}) {
*cond_wait = \&cond_wait_enabled;
*cond_signal = \&cond_signal_enabled;
die "Splice not implemented for shared arrays";
}
-sub UNIVERSAL::shared : ATTR {
- my ($package, $symbol, $referent, $attr, $data, $phase) = @_;
- share($referent);
-}
-
__END__
=head1 NAME
use strict;
+use warnings;
use Config;
BEGIN {
require Test::More;
+use warnings;
+
BEGIN {
# chdir 't' if -d 't';
# push @INC ,'../lib';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
+use warnings;
+
BEGIN {
# chdir 't' if -d 't';
# push @INC ,'../lib';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
ok(3, $foo[0] eq 'hi', "Check assignment works");
$foo[0] = "bar";
ok(4, $foo[0] eq 'bar', "Check overwriting works");
-ok(5, $foo[1] == undef, "Check undef value");
+ok(5, !defined $foo[1], "Check undef value");
$foo[2] = "test";
ok(6, $foo[2] eq "test", "Check extending the array works");
-ok(7, $foo[1] == undef, "Check undef value again");
+ok(7, !defined $foo[1], "Check undef value again");
ok(8, scalar(@foo) == 3, "Check the length of the array");
ok(9,$#foo == 2, "Check last element of array");
threads->create(sub { $foo[0] = "thread1" })->join;
my @foo2;
share @foo2;
my $empty = shift @foo2;
- ok(27, $empty == undef , "Check shift on empty array");
+ ok(27, !defined $empty, "Check shift on empty array");
$empty = pop @foo2;
- ok(28, $empty == undef , "Check pop on empty array");
+ ok(28, !defined $empty, "Check pop on empty array");
}
my $i = 0;
foreach my $var (@foo) {
ok(36, delete($foo[20]) eq "sky", "Check delete works");
threads->create(sub { delete($foo[0])})->join();
-ok(37, delete($foo[0]) == undef, "Check that delete works from a thread");
+ok(37, !defined delete($foo[0]), "Check that delete works from a thread");
@foo = (1,2,3,4,5);
+use warnings;
+
BEGIN {
chdir 't' if -d 't';
push @INC ,'../lib';
+use warnings;
+
BEGIN {
# chdir 't' if -d 't';
# push @INC ,'../lib';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
my %foo;
share(%foo);
$foo{"foo"} = \$foo;
-ok(2, ${$foo{foo}} == undef, "Check deref");
+ok(2, !defined ${$foo{foo}}, "Check deref");
$foo = "test";
ok(3, ${$foo{foo}} eq "test", "Check deref after assign");
threads->create(sub{${$foo{foo}} = "test2";})->join();
skip(10, _thrcnt($gg) == 2, "Check refcount");
my $gg2 = delete($foo{test});
skip(11, _thrcnt($gg) == 1, "Check refcount");
-ok(12, _id($gg) == _id($gg2),
+ok(12, _id($$gg) == _id($$gg2),
sprintf("Check we get the same thing (%x vs %x)",
_id($$gg),_id($$gg2)));
ok(13, $$gg eq $$gg2, "And check the values are the same");
+use warnings;
BEGIN {
# chdir 't' if -d 't';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
my $foo = delete($hash{"bar"});
ok(4, $foo eq "thread1", "Check delete, want 'thread1' got '$foo'");
$foo = delete($hash{"bar"});
- ok(5, $foo == undef, "Check delete on empty value");
+ ok(5, !defined $foo, "Check delete on empty value");
}
ok(6, keys %hash == 1, "Check keys");
$hash{"1"} = 1;
$hash{"2"} = 2;
$hash{"3"} = 3;
ok(7, keys %hash == 4, "Check keys");
-ok(8, exists($hash{"1"}) == 1, "Exist on existing key");
-ok(9, exists($hash{"4"}) == undef, "Exists on non existing key");
+ok(8, exists($hash{"1"}), "Exist on existing key");
+ok(9, !exists($hash{"4"}), "Exists on non existing key");
my %seen;
foreach my $key ( keys %hash) {
$seen{$key}++;
+use warnings;
+
BEGIN {
# chdir 't' if -d 't';
# push @INC ,'../lib';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
-
+use warnings;
BEGIN {
chdir 't' if -d 't';
}
}
-
+use strict;
use threads;
use threads::shared::queue;
-$q = new threads::shared::queue;
+my $q = new threads::shared::queue;
$|++;
print "1..26\n";
+use warnings;
+
BEGIN {
chdir 't' if -d 't';
push @INC ,'../lib';
+use warnings;
BEGIN {
# chdir 't' if -d 't';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
+use warnings;
+
BEGIN {
# chdir 't' if -d 't';
# push @INC ,'../lib';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
-
-
-
+use warnings;
BEGIN {
# chdir 't' if -d 't';
sub ok {
my ($id, $ok, $name) = @_;
+ $name = '' unless defined $name;
# You have to do it this way or VMS will get confused.
print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
switch ((int)len) {
case 6:
switch (*name) {
+ case 's':
+ if (strEQ(name, "shared")) {
+ if (negated)
+ Perl_croak(aTHX_ "A variable may not be unshared");
+ SvSHARE(sv);
+ continue;
+ }
+ break;
case 'u':
if (strEQ(name, "unique")) {
if (SvTYPE(sv) == SVt_PVGV) {