Be explicit about the 5.6.0 dependency
[p5sagit/Devel-GlobalDestruction.git] / lib / Devel / GlobalDestruction.pm
CommitLineData
a91e8a78 1#!/usr/bin/perl
2
3package Devel::GlobalDestruction;
4
5use strict;
6use warnings;
7
53e46d40 8use XSLoader;
a91e8a78 9
d453ae97 10our $VERSION = '0.02';
a91e8a78 11
53e46d40 12XSLoader::load(__PACKAGE__, $VERSION);
a91e8a78 13
14use Sub::Exporter -setup => {
15 exports => [ qw(in_global_destruction) ],
16 groups => { default => [ -all ] },
17};
18
19__PACKAGE__
20
21__END__
22
23=pod
24
25=head1 NAME
26
27Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
28destruction.
29
30=head1 SYNOPSIS
31
32 package Foo;
33 use Devel::GlobalDestruction;
34
35 use namespace::clean; # to avoid having an "in_global_destruction" method
36
37 sub DESTROY {
38 return if in_global_destruction;
39
40 do_something_a_little_tricky();
41 }
42
43=head1 DESCRIPTION
44
45Perl's global destruction is a little tricky to deal with WRT finalizers
46because it's not ordered and objects can sometimes disappear.
47
48Writing defensive destructors is hard and annoying, and usually if global
49destruction is happenning you only need the destructors that free up non
50process local resources to actually execute.
51
52For these constructors you can avoid the mess by simply bailing out if global
53destruction is in effect.
54
55=head1 EXPORTS
56
57This module uses L<Sub::Exporter> so the exports may be renamed, aliased, etc.
58
59=over 4
60
61=item in_global_destruction
62
63Returns the current value of C<PL_dirty>.
64
65=back
66
67=head1 VERSION CONTROL
68
69This module is maintained using Darcs. You can get the latest version from
70L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
71changes.
72
73=head1 AUTHOR
74
75Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
76
77=head1 COPYRIGHT
78
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.
82
83=cut
84
85