ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/common-sense/sense.pm
(Generate patch)

Comparing common-sense/sense.pm (file contents):
Revision 1.2 by root, Thu Jul 9 17:25:48 2009 UTC vs.
Revision 1.3 by root, Thu Jul 9 17:33:40 2009 UTC

73apparently considered O.K., even if it breaks your programs). 73apparently considered O.K., even if it breaks your programs).
74 74
75=item much less memory 75=item much less memory
76 76
77Just using all those pragmas together waste <blink>I<< B<776> kilobytes 77Just using all those pragmas together waste <blink>I<< B<776> kilobytes
78
78>></blink> of precious memory in my perl, for I<every single perl process 79>></blink> of precious memory in my perl, for I<every single perl process
80
79using our code>, which on our machines, is a lot. 81using our code>, which on our machines, is a lot. In comparison, this
82module only uses I<< B<four> >> kilobytes (I even had to write it out so
83it looks like more) of memory on the same platform.
80 84
81The money/time/effort/electricity invested in these gigabytes (probably 85The money/time/effort/electricity invested in these gigabytes (probably
82petabytes globally!) of wasted memory could easily save 42 trees, and a 86petabytes globally!) of wasted memory could easily save 42 trees, and a
83kitten! 87kitten!
84 88
87package common::sense; 91package common::sense;
88 92
89our $VERSION = '0.03'; 93our $VERSION = '0.03';
90 94
91sub import { 95sub import {
96 # no warnings
92 ${^WARNING_BITS} ^= ${^WARNING_BITS}; 97 ${^WARNING_BITS} ^= ${^WARNING_BITS};
98
99 # use strict vars subs
100 $^H |= 0x00000600;
101
102 # use feature
103 $^H{feature_switch} =
104 $^H{feature_say} =
105 $^H{feature_state} = 1;
93} 106}
94 107
95=cut 108=cut
96 109
971; 1101;
98 111
99=back 112=back
100 113
101=head1 EXAMPLE
102
103There really should be a complete C/XS example. Bug me about it.
104
105=head1 IMPLEMENTATION DETAILS AND LIMITATIONS
106
107This module works by "hijacking" SIGKILL, which is guaranteed to be always
108available in perl, but also cannot be caught, so is always available.
109
110Basically, this module fakes the receive of a SIGKILL signal and
111then catches it. This makes normal signal handling slower (probably
112unmeasurably), but has the advantage of not requiring a special runops nor
113slowing down normal perl execution a bit.
114
115It assumes that C<sig_atomic_t> and C<int> are both exception-safe to
116modify (C<sig_atomic_> is used by this module, and perl itself uses
117C<int>, so we can assume that this is quite portable, at least w.r.t.
118signals).
119
120=head1 AUTHOR 114=head1 AUTHOR
121 115
122 Marc Lehmann <schmorp@schmorp.de> 116 Marc Lehmann <schmorp@schmorp.de>
123 http://home.schmorp.de/ 117 http://home.schmorp.de/
124 118

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines