← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:10 2010

File /usr/local/lib/perl/5.10.0/Devel/GlobalDestruction.pm
Statements Executed 20
Total Time 0.0005758 seconds
LineStmts.Exclusive
Time
Avg.Code
1#!/usr/bin/perl
2
3package Devel::GlobalDestruction;
4
5331µs10µsuse strict;
# spent 10µs making 1 call to strict::import
6329µs10µsuse warnings;
# spent 20µs making 1 call to warnings::import
7
8397µs32µsuse vars qw($VERSION @ISA);
# spent 40µs making 1 call to vars::import
9
10BEGIN {
1132µs800ns $VERSION = '0.02';
12
13 local $@;
14
15 eval {
16 require XSLoader;
17 __PACKAGE__->XSLoader::load($VERSION);
# spent 224µs making 1 call to XSLoader::load
18 1;
193240µs80µs } or do {
20 require DynaLoader;
21 push @ISA, 'DynaLoader';
22 __PACKAGE__->bootstrap($VERSION);
23 };
24152µs52µs}
25
26use Sub::Exporter -setup => {
27 exports => [ qw(in_global_destruction) ],
28 groups => { default => [ -all ] },
293120µs40µs};
30
3116µs6µs__PACKAGE__
32
33__END__
34
35=pod
36
37=head1 NAME
38
39Devel::GlobalDestruction - Expose PL_dirty, the flag which marks global
40destruction.
41
42=head1 SYNOPSIS
43
44 package Foo;
45 use Devel::GlobalDestruction;
46
47 use namespace::clean; # to avoid having an "in_global_destruction" method
48
49 sub DESTROY {
50 return if in_global_destruction;
51
52 do_something_a_little_tricky();
53 }
54
55=head1 DESCRIPTION
56
57Perl's global destruction is a little tricky to deal with WRT finalizers
58because it's not ordered and objects can sometimes disappear.
59
60Writing defensive destructors is hard and annoying, and usually if global
61destruction is happenning you only need the destructors that free up non
62process local resources to actually execute.
63
64For these constructors you can avoid the mess by simply bailing out if global
65destruction is in effect.
66
67=head1 EXPORTS
68
69This module uses L<Sub::Exporter> so the exports may be renamed, aliased, etc.
70
71=over 4
72
73=item in_global_destruction
74
75Returns the current value of C<PL_dirty>.
76
77=back
78
79=head1 VERSION CONTROL
80
81This module is maintained using Darcs. You can get the latest version from
82L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
83changes.
84
85=head1 AUTHOR
86
87Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
88
89=head1 COPYRIGHT
90
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.
94
95=cut
96
97