3 package Devel::GlobalDestruction;
10 our $VERSION = '0.02';
12 XSLoader::load(__PACKAGE__, $VERSION);
14 use Sub::Exporter -setup => {
15 exports => [ qw(in_global_destruction) ],
16 groups => { default => [ -all ] },
27 Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
33 use Devel::GlobalDestruction;
35 use namespace::clean; # to avoid having an "in_global_destruction" method
38 return if in_global_destruction;
40 do_something_a_little_tricky();
45 Perl's global destruction is a little tricky to deal with WRT finalizers
46 because it's not ordered and objects can sometimes disappear.
48 Writing defensive destructors is hard and annoying, and usually if global
49 destruction is happenning you only need the destructors that free up non
50 process local resources to actually execute.
52 For these constructors you can avoid the mess by simply bailing out if global
53 destruction is in effect.
57 This module uses L<Sub::Exporter> so the exports may be renamed, aliased, etc.
61 =item in_global_destruction
63 Returns the current value of C<PL_dirty>.
67 =head1 VERSION CONTROL
69 This module is maintained using Darcs. You can get the latest version from
70 L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
75 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
79 Copyright (c) 2008 Yuval Kogman. All rights reserved
80 This program is free software; you can redistribute
81 it and/or modify it under the same terms as Perl itself.