1Devel::GlobalDestructioUns(e3r)Contributed Perl DocumentDaetvieoln::GlobalDestruction(3)
2
3
4
6 Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
7 destruction.
8
10 package Foo;
11 use Devel::GlobalDestruction;
12
13 use namespace::clean; # to avoid having an "in_global_destruction" method
14
15 sub DESTROY {
16 return if in_global_destruction;
17
18 do_something_a_little_tricky();
19 }
20
22 Perl's global destruction is a little tricky to deal with WRT
23 finalizers because it's not ordered and objects can sometimes
24 disappear.
25
26 Writing defensive destructors is hard and annoying, and usually if
27 global destruction is happenning you only need the destructors that
28 free up non process local resources to actually execute.
29
30 For these constructors you can avoid the mess by simply bailing out if
31 global destruction is in effect.
32
34 This module uses Sub::Exporter so the exports may be renamed, aliased,
35 etc.
36
37 in_global_destruction
38 Returns the current value of "PL_dirty".
39
41 This module is maintained using Darcs. You can get the latest version
42 from <http://nothingmuch.woobling.org/code>, and use "darcs send" to
43 commit changes.
44
46 Yuval Kogman <nothingmuch@woobling.org>
47
49 Copyright (c) 2008 Yuval Kogman. All rights reserved
50 This program is free software; you can redistribute
51 it and/or modify it under the same terms as Perl itself.
52
53
54
55perl v5.12.0 2008-08-09 Devel::GlobalDestruction(3)