X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDevel%2FGlobalDestruction.pm;h=8cf559c61febd481f5dfa816bce4f3f4e64e14ea;hb=aaa7f60fc32505c436095fb1e5a91b8bc11f3e3a;hp=d2427273bf6ebef8312733e6c8360249eeb00d61;hpb=f615b0ff13c3d7547cca03c37f2877bb8307b709;p=p5sagit%2FDevel-GlobalDestruction.git diff --git a/lib/Devel/GlobalDestruction.pm b/lib/Devel/GlobalDestruction.pm index d242727..8cf559c 100644 --- a/lib/Devel/GlobalDestruction.pm +++ b/lib/Devel/GlobalDestruction.pm @@ -5,26 +5,22 @@ package Devel::GlobalDestruction; use strict; use warnings; -use vars qw($VERSION @ISA); +use XSLoader; -BEGIN { - $VERSION = '0.02'; - - - if ( do { local $@; eval { require XSLoader; 1 } } ) { - __PACKAGE__->XSLoader::load($VERSION); - } else { - require DynaLoader; - push @ISA, 'DynaLoader'; - __PACKAGE__->bootstrap($VERSION); - } -} +our $VERSION = '0.04'; use Sub::Exporter -setup => { exports => [ qw(in_global_destruction) ], groups => { default => [ -all ] }, }; +if (defined ${^GLOBAL_PHASE}) { + eval 'sub in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }'; +} +else { + XSLoader::load(__PACKAGE__, $VERSION); +} + __PACKAGE__ __END__ @@ -33,7 +29,7 @@ __END__ =head1 NAME -Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global +Devel::GlobalDestruction - Expose the flag which marks global destruction. =head1 SYNOPSIS @@ -69,7 +65,9 @@ This module uses L so the exports may be renamed, aliased, etc. =item in_global_destruction -Returns the current value of C. +Returns true if the interpreter is in global destruction. In perl 5.14+, this +returns C<${^GLOBAL_PHASE} eq 'DESTRUCT'>, and on earlier perls, it returns the +current value of C. =back @@ -79,10 +77,14 @@ This module is maintained using Darcs. You can get the latest version from L, and use C to commit changes. -=head1 AUTHOR +=head1 AUTHORS Yuval Kogman Enothingmuch@woobling.orgE +Florian Ragwitz Erafl@debian.orgE + +Jesse Luehrs Edoy@tozt.netE + =head1 COPYRIGHT Copyright (c) 2008 Yuval Kogman. All rights reserved