3 package Devel::GlobalDestruction;
8 use vars qw($VERSION @ISA);
17 __PACKAGE__->XSLoader::load($VERSION);
21 push @ISA, 'DynaLoader';
22 __PACKAGE__->bootstrap($VERSION);
26 use Sub::Exporter -setup => {
27 exports => [ qw(in_global_destruction) ],
28 groups => { default => [ -all ] },
39 Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
45 use Devel::GlobalDestruction;
47 use namespace::clean; # to avoid having an "in_global_destruction" method
50 return if in_global_destruction;
52 do_something_a_little_tricky();
57 Perl's global destruction is a little tricky to deal with WRT finalizers
58 because it's not ordered and objects can sometimes disappear.
60 Writing defensive destructors is hard and annoying, and usually if global
61 destruction is happenning you only need the destructors that free up non
62 process local resources to actually execute.
64 For these constructors you can avoid the mess by simply bailing out if global
65 destruction is in effect.
69 This module uses L<Sub::Exporter> so the exports may be renamed, aliased, etc.
73 =item in_global_destruction
75 Returns the current value of C<PL_dirty>.
79 =head1 VERSION CONTROL
81 This module is maintained using Darcs. You can get the latest version from
82 L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
87 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
91 Copyright (c) 2008 Yuval Kogman. All rights reserved
92 This program is free software; you can redistribute
93 it and/or modify it under the same terms as Perl itself.