| 1 |
NAME |
| 2 |
Devel::GlobalDestruction - Provides function returning the equivalent of |
| 3 |
"${^GLOBAL_PHASE} eq 'DESTRUCT'" for older perls. |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
package Foo; |
| 7 |
use Devel::GlobalDestruction; |
| 8 |
|
| 9 |
use namespace::clean; # to avoid having an "in_global_destruction" method |
| 10 |
|
| 11 |
sub DESTROY { |
| 12 |
return if in_global_destruction; |
| 13 |
|
| 14 |
do_something_a_little_tricky(); |
| 15 |
} |
| 16 |
|
| 17 |
DESCRIPTION |
| 18 |
Perl's global destruction is a little tricky to deal with WRT finalizers |
| 19 |
because it's not ordered and objects can sometimes disappear. |
| 20 |
|
| 21 |
Writing defensive destructors is hard and annoying, and usually if |
| 22 |
global destruction is happening you only need the destructors that free |
| 23 |
up non process local resources to actually execute. |
| 24 |
|
| 25 |
For these constructors you can avoid the mess by simply bailing out if |
| 26 |
global destruction is in effect. |
| 27 |
|
| 28 |
EXPORTS |
| 29 |
This module uses Sub::Exporter::Progressive so the exports may be |
| 30 |
renamed, aliased, etc. if Sub::Exporter is present. |
| 31 |
|
| 32 |
in_global_destruction |
| 33 |
Returns true if the interpreter is in global destruction. In perl |
| 34 |
5.14+, this returns "${^GLOBAL_PHASE} eq 'DESTRUCT'", and on earlier |
| 35 |
perls, detects it using the value of "PL_main_cv" or "PL_dirty". |
| 36 |
|
| 37 |
AUTHORS |
| 38 |
Yuval Kogman <[email protected]> |
| 39 |
|
| 40 |
Florian Ragwitz <[email protected]> |
| 41 |
|
| 42 |
Jesse Luehrs <[email protected]> |
| 43 |
|
| 44 |
Peter Rabbitson <[email protected]> |
| 45 |
|
| 46 |
Arthur Axel 'fREW' Schmidt <[email protected]> |
| 47 |
|
| 48 |
Elizabeth Mattijsen <[email protected]> |
| 49 |
|
| 50 |
Greham Knop <[email protected]> |
| 51 |
|
| 52 |
COPYRIGHT |
| 53 |
Copyright (c) 2008 Yuval Kogman. All rights reserved |
| 54 |
This program is free software; you can redistribute |
| 55 |
it and/or modify it under the same terms as Perl itself. |
| 56 |
|