3 package Devel::GlobalDestruction;
8 use vars qw($VERSION @ISA);
14 if ( do { local $@; eval { require XSLoader; 1 } } ) {
15 __PACKAGE__->XSLoader::load($VERSION);
18 push @ISA, 'DynaLoader';
19 __PACKAGE__->bootstrap($VERSION);
23 use Sub::Exporter -setup => {
24 exports => [ qw(in_global_destruction) ],
25 groups => { default => [ -all ] },
36 Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
42 use Devel::GlobalDestruction;
44 use namespace::clean; # to avoid having an "in_global_destruction" method
47 return if in_global_destruction;
49 do_something_a_little_tricky();
54 Perl's global destruction is a little tricky to deal with WRT finalizers
55 because it's not ordered and objects can sometimes disappear.
57 Writing defensive destructors is hard and annoying, and usually if global
58 destruction is happenning you only need the destructors that free up non
59 process local resources to actually execute.
61 For these constructors you can avoid the mess by simply bailing out if global
62 destruction is in effect.
66 This module uses L<Sub::Exporter> so the exports may be renamed, aliased, etc.
70 =item in_global_destruction
72 Returns the current value of C<PL_dirty>.
76 =head1 VERSION CONTROL
78 This module is maintained using Darcs. You can get the latest version from
79 L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
84 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
88 Copyright (c) 2008 Yuval Kogman. All rights reserved
89 This program is free software; you can redistribute
90 it and/or modify it under the same terms as Perl itself.