From: Jarkko Hietaniemi Date: Wed, 17 Apr 2002 14:31:42 +0000 (+0000) Subject: As suggested by Arthur: the threads and threads::shared X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=73e09c8fa5daeb8994c6d0aff5cfb8c4e65a7150;p=p5sagit%2Fp5-mst-13.2.git As suggested by Arthur: the threads and threads::shared modules are always present. This tries to preempt two kinds of bug reports: (1) "the Perl 5.8.0 was supposed to have this new fancy threads implementation but my Perl doesn't seem to have it" (2) someone attempting to install threads using CPAN.pm and CPAN.pm helpfully starting to install perl 5.8.0 (which they might already have installed). p4raw-id: //depot/perl@15972 --- diff --git a/Configure b/Configure index 57e166c..7225e61 100755 --- a/Configure +++ b/Configure @@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Wed Apr 17 02:10:04 EET DST 2002 [metaconfig 3.0 PL70] +# Generated on Wed Apr 17 17:49:13 EET DST 2002 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.org) cat >c1$$ < 'threads', 'VERSION_FROM' => 'threads.pm', # finds $VERSION diff --git a/ext/threads/shared/Makefile.PL b/ext/threads/shared/Makefile.PL index 3a4c6e3..046e6e4 100755 --- a/ext/threads/shared/Makefile.PL +++ b/ext/threads/shared/Makefile.PL @@ -2,13 +2,6 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. -use Config; - - -unless($Config{'useithreads'} eq 'define') { - die "We need a perl that is built with USEITHREAD!\n"; -} - WriteMakefile( 'NAME' => 'threads::shared', 'VERSION_FROM' => 'shared.pm', # finds $VERSION diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm index 83bd92c..03949cb 100644 --- a/ext/threads/shared/shared.pm +++ b/ext/threads/shared/shared.pm @@ -1,8 +1,32 @@ package threads::shared; + +use 5.007_003; use strict; use warnings; use Config; +BEGIN { + unless ($Config{useithreads}) { + my @caller = caller(2); + die <sv) /* @@ -749,10 +751,13 @@ Perl_sharedsv_init(pTHX) PL_sharehook = &Perl_sharedsv_share; } +#endif /* USE_ITHREADS */ + MODULE = threads::shared PACKAGE = threads::shared::tie PROTOTYPES: DISABLE +#ifdef USE_ITHREADS void PUSH(shared_sv *shared, ...) @@ -1005,7 +1010,14 @@ cond_broadcast_enabled(SV *ref) croak("cond_broadcast can only be used on shared values"); COND_BROADCAST(&shared->user_cond); +#endif /* USE_ITHREADS */ + BOOT: { +#ifdef USE_ITHREADS Perl_sharedsv_init(aTHX); +#endif /* USE_ITHREADS */ } + + + diff --git a/ext/threads/threads.pm b/ext/threads/threads.pm index 12a9afa..11878eb 100755 --- a/ext/threads/threads.pm +++ b/ext/threads/threads.pm @@ -1,8 +1,31 @@ package threads; -use 5.007_002; +use 5.007_003; use strict; use warnings; +use Config; + +BEGIN { + unless ($Config{useithreads}) { + my @caller = caller(2); + die < \&equal, diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 891fdb0..db76082 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -3,6 +3,8 @@ #include "perl.h" #include "XSUB.h" +#ifdef USE_ITHREADS + #ifdef WIN32 #include #include @@ -516,11 +518,13 @@ Perl_ithread_DESTROY(pTHX_ SV *sv) sv_unmagic(SvRV(sv),PERL_MAGIC_shared_scalar); } - +#endif /* USE_ITHREADS */ MODULE = threads PACKAGE = threads PREFIX = ithread_ PROTOTYPES: DISABLE +#ifdef USE_ITHREADS + void ithread_new (classname, function_to_call, ...) char * classname @@ -569,8 +573,11 @@ ithread_detach(ithread *thread) void ithread_DESTROY(SV *thread) +#endif /* USE_ITHREADS */ + BOOT: { +#ifdef USE_ITHREADS ithread* thread; PL_perl_destruct_level = 2; PERL_THREAD_ALLOC_SPECIFIC(self_key); @@ -598,5 +605,6 @@ BOOT: PERL_THREAD_SETSPECIFIC(self_key,thread); MUTEX_UNLOCK(&create_destruct_mutex); +#endif /* USE_ITHREADS */ }