… | |
… | |
38 | |
38 | |
39 | You can use this module to bind a signal to a callback while at the same |
39 | You can use this module to bind a signal to a callback while at the same |
40 | time activating an event pipe that you can C<select> on, fixing the race |
40 | time activating an event pipe that you can C<select> on, fixing the race |
41 | completely. |
41 | completely. |
42 | |
42 | |
43 | This can be used to implement the signal hadling in event loops, |
43 | This can be used to implement the signal handling in event loops, |
44 | e.g. L<AnyEvent>, L<POE>, L<IO::Async::Loop> and so on. |
44 | e.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 | |
48 | Assume you want very exact timing, and you can spare an extra cpu core |
48 | Assume 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 | |
160 | So to repeat: first the XS object is created, then it is queried for the |
160 | So to repeat: first the XS object is created, then it is queried for the |
161 | callback that should be called when the Interrupt object gets signalled. |
161 | callback that should be called when the Interrupt object gets signalled. |
162 | |
162 | |
163 | Then the interrupt object is queried for the callback fucntion that the |
163 | Then the interrupt object is queried for the callback function that the |
164 | thread should call to signal the Interrupt object, and this callback is |
164 | thread should call to signal the Interrupt object, and this callback is |
165 | then attached to the thread. |
165 | then attached to the thread. |
166 | |
166 | |
167 | You have to be careful that your new thread is not signalling before the |
167 | You have to be careful that your new thread is not signalling before the |
168 | signal function was configured, for example by starting the background |
168 | signal 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.23; |
241 | our $VERSION = 1.26; |
242 | |
242 | |
243 | require XSLoader; |
243 | require XSLoader; |
244 | XSLoader::load ("Async::Interrupt", $VERSION); |
244 | XSLoader::load ("Async::Interrupt", $VERSION); |
245 | } |
245 | } |
246 | |
246 | |
… | |
… | |
615 | |
615 | |
616 | An example call would look like: |
616 | An example call would look like: |
617 | |
617 | |
618 | c_func (c_arg); |
618 | c_func (c_arg); |
619 | |
619 | |
620 | =item $epipe->post_fork |
620 | =item $epipe->renew |
621 | |
621 | |
622 | Recreates the pipe (usually required in the child after a fork). The |
622 | Recreates the pipe (usually required in the child after a fork). The |
623 | reading side will not change it's file descriptor number, but the writing |
623 | reading side will not change it's file descriptor number, but the writing |
624 | side might. |
624 | side might. |
625 | |
625 | |
… | |
… | |
638 | =head1 IMPLEMENTATION DETAILS AND LIMITATIONS |
638 | =head1 IMPLEMENTATION DETAILS AND LIMITATIONS |
639 | |
639 | |
640 | This module works by "hijacking" SIGKILL, which is guaranteed to always |
640 | This module works by "hijacking" SIGKILL, which is guaranteed to always |
641 | exist, but also cannot be caught, so is always available. |
641 | exist, but also cannot be caught, so is always available. |
642 | |
642 | |
643 | Basically, this module fakes the occurance of a SIGKILL signal and |
643 | Basically, this module fakes the occurence of a SIGKILL signal and |
644 | then intercepts the interpreter handling it. This makes normal signal |
644 | then intercepts the interpreter handling it. This makes normal signal |
645 | handling slower (probably unmeasurably, though), but has the advantage |
645 | handling slower (probably unmeasurably, though), but has the advantage |
646 | of not requiring a special runops function, nor slowing down normal perl |
646 | of not requiring a special runops function, nor slowing down normal perl |
647 | execution a bit. |
647 | execution a bit. |
648 | |
648 | |