3 package Devel::GlobalDestruction;
10 our $VERSION = '0.03';
12 use Sub::Exporter -setup => {
13 exports => [ qw(in_global_destruction) ],
14 groups => { default => [ -all ] },
18 eval 'sub in_global_destruction () { ${^GLOBAL_PHASE} eq q[DESTRUCT] }';
21 XSLoader::load(__PACKAGE__, $VERSION);
32 Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
38 use Devel::GlobalDestruction;
40 use namespace::clean; # to avoid having an "in_global_destruction" method
43 return if in_global_destruction;
45 do_something_a_little_tricky();
50 Perl's global destruction is a little tricky to deal with WRT finalizers
51 because it's not ordered and objects can sometimes disappear.
53 Writing defensive destructors is hard and annoying, and usually if global
54 destruction is happenning you only need the destructors that free up non
55 process local resources to actually execute.
57 For these constructors you can avoid the mess by simply bailing out if global
58 destruction is in effect.
62 This module uses L<Sub::Exporter> so the exports may be renamed, aliased, etc.
66 =item in_global_destruction
68 Returns the current value of C<PL_dirty>.
72 =head1 VERSION CONTROL
74 This module is maintained using Darcs. You can get the latest version from
75 L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
80 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
82 Florian Ragwitz E<lt>rafl@debian.orgE<gt>
86 Copyright (c) 2008 Yuval Kogman. All rights reserved
87 This program is free software; you can redistribute
88 it and/or modify it under the same terms as Perl itself.