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.29 by root, Tue Apr 24 20:52:35 2012 UTC vs.
Revision 1.33 by root, Fri Apr 11 04:24:47 2014 UTC

114callback just sets a global variable, as we are only interested in 114callback just sets a global variable, as we are only interested in
115synchronous signals (i.e. when the event loop polls), which is why the 115synchronous signals (i.e. when the event loop polls), which is why the
116pipe draining is not done automatically. 116pipe draining is not done automatically.
117 117
118 my $interrupt = new Async::Interrupt 118 my $interrupt = new Async::Interrupt
119 cb => sub { undef $SIGNAL_RECEIVED{$signum} } 119 cb => sub { undef $SIGNAL_RECEIVED{$signum} },
120 signal => $signum, 120 signal => $signum,
121 pipe => [$SIGPIPE->filenos], 121 pipe => [$SIGPIPE->filenos],
122 pipe_autodrain => 0, 122 pipe_autodrain => 0,
123 ; 123 ;
124 124
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.05'; 241 our $VERSION = '1.2';
242 242
243 require XSLoader; 243 require XSLoader;
244 XSLoader::load ("Async::Interrupt", $VERSION); 244 XSLoader::load ("Async::Interrupt", $VERSION);
245} 245}
246 246
419might imply, do anything with POSIX signals). 419might imply, do anything with POSIX signals).
420 420
421C<$value> must be in the valid range for a C<sig_atomic_t>, except C<0> 421C<$value> must be in the valid range for a C<sig_atomic_t>, except C<0>
422(1..127 is portable). 422(1..127 is portable).
423 423
424=item $async->handle
425
426Calls the callback if the object is pending.
427
428This method does not need to be called normally, as it will be invoked
429automatically. However, it can be used to force handling of outstanding
430interrupts while the object is blocked.
431
432One reason why one might want to do that is when you want to switch
433from asynchronous interruptions to synchronous one, using e.g. an event
434loop. To do that, one would first C<< $async->block >> the interrupt
435object, then register a read watcher on the C<pipe_fileno> that calls C<<
436$async->handle >>.
437
438This disables asynchronous interruptions, but ensures that interrupts are
439handled by the event loop.
440
424=item $async->signal_hysteresis ($enable) 441=item $async->signal_hysteresis ($enable)
425 442
426Enables or disables signal hysteresis (default: disabled). If a POSIX 443Enables or disables signal hysteresis (default: disabled). If a POSIX
427signal is used as a signal source for the interrupt object, then enabling 444signal is used as a signal source for the interrupt object, then enabling
428signal hysteresis causes Async::Interrupt to reset the signal action to 445signal hysteresis causes Async::Interrupt to reset the signal action to
510draining. 527draining.
511 528
512This is useful when you want to share one pipe among many Async::Interrupt 529This is useful when you want to share one pipe among many Async::Interrupt
513objects. 530objects.
514 531
532=item $async->pipe_drain
533
534Drains the pipe manually, for example, when autodrain is disabled. Does
535nothing when no pipe is enabled.
536
515=item $async->post_fork 537=item $async->post_fork
516 538
517The object will not normally be usable after a fork (as the pipe fd is 539The object will not normally be usable after a fork (as the pipe fd is
518shared between processes). Calling this method after a fork in the child 540shared between processes). Calling this method after a fork in the child
519ensures that the object will work as expected again. It only needs to be 541ensures that the object will work as expected again. It only needs to be

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines