From: Jarkko Hietaniemi Date: Thu, 20 Jun 2002 00:23:35 +0000 (+0000) Subject: (retracted by #17321) Make Getopt::Long ithread-safe. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d40167621925b3e6ee89773cf75c1bb79880d06;p=p5sagit%2Fp5-mst-13.2.git (retracted by #17321) Make Getopt::Long ithread-safe. p4raw-id: //depot/perl@17316 --- diff --git a/lib/Getopt/Long.pm b/lib/Getopt/Long.pm index 0ab862a..2c3247e 100644 --- a/lib/Getopt/Long.pm +++ b/lib/Getopt/Long.pm @@ -132,6 +132,21 @@ ConfigDefaults(); package Getopt::Long::Parser; +# Make Getopt::Long thread-safe for ithreads. +BEGIN { + use Config; + if( $] >= 5.008 && $Config{useithreads} ) { + require threads; + require threads::shared; + threads::shared->import; + share(\$Getopt::Long::error); + } + else { + *lock = sub { 0 }; + } +} + + # NOTE: The object oriented routines use $error for thread locking. my $_lock = sub { lock ($Getopt::Long::error) if $] >= 5.005