From: Artur Bergman Date: Tue, 9 Jul 2002 21:23:31 +0000 (+0000) Subject: Update documentation with &share() non prototype checking version. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=caf25f3be4a66b8fbb51db2cfdfa658f6b9704e7;p=p5sagit%2Fp5-mst-13.2.git Update documentation with &share() non prototype checking version. Fix share so it once again returns a reference to whatever it just shared, so now you can do my &share([]); Remove check for useithreads and Config.pm from threads::shared, you can now always use threads::shared in your module without overhead of config.pm and without speed hit unless threads have been requested, share, cond_wait, cond_broadcast, cond_signal and lock all become noops, so does : share. p4raw-id: //depot/perl@17453 --- diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm index 8f3c677..d7d67de 100644 --- a/ext/threads/shared/shared.pm +++ b/ext/threads/shared/shared.pm @@ -3,36 +3,13 @@ package threads::shared; use 5.007_003; use strict; use warnings; -use Config; - -BEGIN { - unless ($Config{useithreads}) { - my @caller = caller(2); - die < is equivalent to C, while C is not. A variable can also be marked as shared at compile time by using the C attribute: C. +If you want to share a newly created reference, unfourtunetly you need to use +C<&share([])> and C<&share({})> syntax due to problems with perls prototyping. + =item lock VARIABLE C places a lock on a variable until the lock goes out of scope. If diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs index 14524f6..2a08fb0 100644 --- a/ext/threads/shared/shared.xs +++ b/ext/threads/shared/shared.xs @@ -743,7 +743,6 @@ Perl_sharedsv_locksv(pTHX_ SV *sv) =for apidoc sharedsv_init Saves a space for keeping SVs wider than an interpreter, -currently only stores a pointer to the first interpreter. =cut @@ -955,7 +954,7 @@ CODE: } XSRETURN_UNDEF; -void +SV* share(SV *ref) PROTOTYPE: \[$@%] CODE: @@ -963,6 +962,9 @@ share(SV *ref) if(SvROK(ref)) ref = SvRV(ref); Perl_sharedsv_share(aTHX_ ref); + RETVAL = newRV(ref); + OUTPUT: + RETVAL void lock_enabled(SV *ref)