diff options
Diffstat (limited to 'lib/Getopt/Long.pm')
-rw-r--r-- | lib/Getopt/Long.pm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Getopt/Long.pm b/lib/Getopt/Long.pm index 0ab862a25a..2c3247e729 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 |