ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Async-Interrupt/Interrupt.pm
(Generate patch)

Comparing cvsroot/Async-Interrupt/Interrupt.pm (file contents):
Revision 1.32 by root, Mon Jun 10 05:37:58 2013 UTC vs.
Revision 1.39 by root, Thu Jul 18 09:13:00 2019 UTC

38 38
39You can use this module to bind a signal to a callback while at the same 39You can use this module to bind a signal to a callback while at the same
40time activating an event pipe that you can C<select> on, fixing the race 40time activating an event pipe that you can C<select> on, fixing the race
41completely. 41completely.
42 42
43This can be used to implement the signal hadling in event loops, 43This can be used to implement the signal handling in event loops,
44e.g. L<AnyEvent>, L<POE>, L<IO::Async::Loop> and so on. 44e.g. L<AnyEvent>, L<POE>, L<IO::Async::Loop> and so on.
45 45
46=item Background threads want speedy reporting 46=item Background threads want speedy reporting
47 47
48Assume you want very exact timing, and you can spare an extra cpu core 48Assume you want very exact timing, and you can spare an extra cpu core
158 _attach $self, $asy->signal_func; 158 _attach $self, $asy->signal_func;
159 159
160So to repeat: first the XS object is created, then it is queried for the 160So to repeat: first the XS object is created, then it is queried for the
161callback that should be called when the Interrupt object gets signalled. 161callback that should be called when the Interrupt object gets signalled.
162 162
163Then the interrupt object is queried for the callback fucntion that the 163Then the interrupt object is queried for the callback function that the
164thread should call to signal the Interrupt object, and this callback is 164thread should call to signal the Interrupt object, and this callback is
165then attached to the thread. 165then attached to the thread.
166 166
167You have to be careful that your new thread is not signalling before the 167You have to be careful that your new thread is not signalling before the
168signal function was configured, for example by starting the background 168signal function was configured, for example by starting the background
236 # the next line forces initialisation of internal 236 # the next line forces initialisation of internal
237 # signal handling variables, otherwise, PL_sig_pending 237 # signal handling variables, otherwise, PL_sig_pending
238 # etc. might be null pointers. 238 # etc. might be null pointers.
239 $SIG{KILL} = sub { }; 239 $SIG{KILL} = sub { };
240 240
241 our $VERSION = '1.1'; 241 our $VERSION = 1.25;
242 242
243 require XSLoader; 243 require XSLoader;
244 XSLoader::load ("Async::Interrupt", $VERSION); 244 XSLoader::load ("Async::Interrupt", $VERSION);
245} 245}
246 246
617 617
618 c_func (c_arg); 618 c_func (c_arg);
619 619
620=item $epipe->renew 620=item $epipe->renew
621 621
622Recreates the pipe (useful after a fork). The reading side will not change 622Recreates the pipe (usually required in the child after a fork). The
623it's file descriptor number, but the writing side might. 623reading side will not change it's file descriptor number, but the writing
624side might.
624 625
625=item $epipe->wait 626=item $epipe->wait
626 627
627This method blocks the process until there are events on the pipe. This is 628This method blocks the process until there are events on the pipe. This is
628not a very event-based or ncie way of usign an event pipe, but it can be 629not a very event-based or ncie way of usign an event pipe, but it can be
637=head1 IMPLEMENTATION DETAILS AND LIMITATIONS 638=head1 IMPLEMENTATION DETAILS AND LIMITATIONS
638 639
639This module works by "hijacking" SIGKILL, which is guaranteed to always 640This module works by "hijacking" SIGKILL, which is guaranteed to always
640exist, but also cannot be caught, so is always available. 641exist, but also cannot be caught, so is always available.
641 642
642Basically, this module fakes the occurance of a SIGKILL signal and 643Basically, this module fakes the occurence of a SIGKILL signal and
643then intercepts the interpreter handling it. This makes normal signal 644then intercepts the interpreter handling it. This makes normal signal
644handling slower (probably unmeasurably, though), but has the advantage 645handling slower (probably unmeasurably, though), but has the advantage
645of not requiring a special runops function, nor slowing down normal perl 646of not requiring a special runops function, nor slowing down normal perl
646execution a bit. 647execution a bit.
647 648

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines