1Devel::GlobalDestructioUns(e3r)Contributed Perl DocumentDaetvieoln::GlobalDestruction(3)
2
3
4

NAME

6       Devel::GlobalDestruction - Provides function returning the equivalent
7       of "${^GLOBAL_PHASE} eq 'DESTRUCT'" for older perls.
8

SYNOPSIS

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

DESCRIPTION

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 happening you only need the destructors that free
28       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

EXPORTS

34       This module uses Sub::Exporter::Progressive so the exports may be
35       renamed, aliased, etc. if Sub::Exporter is present.
36
37       in_global_destruction
38           Returns true if the interpreter is in global destruction. In perl
39           5.14+, this returns "${^GLOBAL_PHASE} eq 'DESTRUCT'", and on
40           earlier perls, detects it using the value of "PL_main_cv" or
41           "PL_dirty".
42

AUTHORS

44       Yuval Kogman <nothingmuch@woobling.org>
45
46       Florian Ragwitz <rafl@debian.org>
47
48       Jesse Luehrs <doy@tozt.net>
49
50       Peter Rabbitson <ribasushi@cpan.org>
51
52       Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
53
54       Elizabeth Mattijsen <liz@dijkmat.nl>
55
56       Greham Knop <haarg@haarg.org>
57
59           Copyright (c) 2008 Yuval Kogman. All rights reserved
60           This program is free software; you can redistribute
61           it and/or modify it under the same terms as Perl itself.
62
63
64
65perl v5.34.0                      2021-07-22       Devel::GlobalDestruction(3)
Impressum