From: Jerry D. Hedden Date: Wed, 5 Sep 2007 09:50:24 +0000 (-0400) Subject: threads::shared 1.13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c8caac01fed14372509c397e3e7b8ddc0ce3513;p=p5sagit%2Fp5-mst-13.2.git threads::shared 1.13 From: "Jerry D. Hedden" Message-ID: <1ff86f510709050650j3c3f54b2o64c8ce05dc4c8604@mail.gmail.com> p4raw-id: //depot/perl@31795 --- diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm index fe8cf6e..06829a1 100644 --- a/ext/threads/shared/shared.pm +++ b/ext/threads/shared/shared.pm @@ -5,7 +5,7 @@ use 5.008; use strict; use warnings; -our $VERSION = '1.12'; +our $VERSION = '1.13'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -73,7 +73,7 @@ threads::shared - Perl extension for sharing data structures between threads =head1 VERSION -This document describes threads::shared version 1.12 +This document describes threads::shared version 1.13 =head1 SYNOPSIS @@ -108,7 +108,7 @@ This document describes threads::shared version 1.12 By default, variables are private to each thread, and each newly created thread gets a private copy of each existing variable. This module allows you -to share variables across different threads (and pseudoforks on Win32). It is +to share variables across different threads (and pseudo-forks on Win32). It is used together with the L module. =head1 EXPORT @@ -205,11 +205,11 @@ the variable, and blocks until another thread does a C or C for that same locked variable. The variable that C blocked on is relocked after the C is satisfied. If there are multiple threads Cing on the same variable, all but one -will reblock waiting to reacquire the lock on the variable. (So if you're only +will re-block waiting to reacquire the lock on the variable. (So if you're only using C for synchronisation, give up the lock as soon as possible). The two actions of unlocking the variable and entering the blocked wait state are atomic, the two actions of exiting from the blocked wait state and -relocking the variable are not. +re-locking the variable are not. In its second form, C takes a shared, B variable followed by a shared, B variable. The second variable is unlocked and thread @@ -368,7 +368,7 @@ L Discussion Forum on CPAN: L Annotated POD for L: -L +L Source repository: L diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs index b8c057a..4115bf1 100644 --- a/ext/threads/shared/shared.xs +++ b/ext/threads/shared/shared.xs @@ -1328,7 +1328,10 @@ _refcnt(SV *ref) ref = SvRV(ref); ssv = Perl_sharedsv_find(aTHX_ ref); if (! ssv) { - Perl_warn(aTHX_ "%" SVf " is not shared", ST(0)); + if (ckWARN(WARN_THREADS)) { + Perl_warner(aTHX_ packWARN(WARN_THREADS), + "%" SVf " is not shared", ST(0)); + } XSRETURN_UNDEF; } ST(0) = sv_2mortal(newSViv(SvREFCNT(ssv))); diff --git a/ext/threads/shared/t/0nothread.t b/ext/threads/shared/t/0nothread.t index 0e5216e..0808277 100644 --- a/ext/threads/shared/t/0nothread.t +++ b/ext/threads/shared/t/0nothread.t @@ -77,7 +77,7 @@ if ($threads::shared::VERSION && ! exists($ENV{'PERL_CORE'})) { array(24, [], 'Thing'); hash(24, [], 'Thing'); -import threads::shared; +threads::shared->import(); share(\@array); array(24, 42, 'Thing'); diff --git a/ext/threads/shared/t/blessed.t b/ext/threads/shared/t/blessed.t index 4408c36..91a2ac3 100644 --- a/ext/threads/shared/t/blessed.t +++ b/ext/threads/shared/t/blessed.t @@ -99,28 +99,28 @@ ok(23, ref($$hobj{'array'}) eq 'yang', "blessed array in hash"); ok(24, ref($$hobj{'scalar'}) eq 'baz', "blessed scalar in hash"); ok(25, ${$$hobj{'scalar'}} eq '3', "blessed scalar in hash contents"); -threads->new(sub { - # Rebless objects - bless $hobj, 'oof'; - bless $aobj, 'rab'; - bless $sobj, 'zab'; - - my $data = $$aobj[0]; - bless $data, 'niy'; - $$aobj[0] = $data; - $data = $$aobj[1]; - bless $data, 'gnay'; - $$aobj[1] = $data; - - $data = $$hobj{'hash'}; - bless $data, 'niy'; - $$hobj{'hash'} = $data; - $data = $$hobj{'array'}; - bless $data, 'gnay'; - $$hobj{'array'} = $data; - - $$sobj = 'test'; - })->join; +threads->create(sub { + # Rebless objects + bless $hobj, 'oof'; + bless $aobj, 'rab'; + bless $sobj, 'zab'; + + my $data = $$aobj[0]; + bless $data, 'niy'; + $$aobj[0] = $data; + $data = $$aobj[1]; + bless $data, 'gnay'; + $$aobj[1] = $data; + + $data = $$hobj{'hash'}; + bless $data, 'niy'; + $$hobj{'hash'} = $data; + $data = $$hobj{'array'}; + bless $data, 'gnay'; + $$hobj{'array'} = $data; + + $$sobj = 'test'; + })->join(); # Test reblessing ok(26, ref($hobj) eq 'oof', "hash reblessing does work"); diff --git a/ext/threads/shared/t/waithires.t b/ext/threads/shared/t/waithires.t index 7c5ee7c..22e9c73 100644 --- a/ext/threads/shared/t/waithires.t +++ b/ext/threads/shared/t/waithires.t @@ -13,7 +13,7 @@ BEGIN { } eval { require Time::HiRes; - import Time::HiRes qw(time); + Time::HiRes->import('time'); }; if ($@) { print("1..0 # Skip: Time::HiRes not available.\n");