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

Comparing EV/EV.pm (file contents):
Revision 1.114 by root, Wed Apr 15 19:35:53 2009 UTC vs.
Revision 1.125 by root, Thu Dec 31 06:59:47 2009 UTC

76 76
77=cut 77=cut
78 78
79package EV; 79package EV;
80 80
81no warnings; 81use common::sense;
82use strict;
83 82
84BEGIN { 83BEGIN {
85 our $VERSION = '3.53'; 84 our $VERSION = '3.9';
86 use XSLoader; 85 use XSLoader;
87 XSLoader::load "EV", $VERSION; 86 XSLoader::load "EV", $VERSION;
88} 87}
89 88
90@EV::IO::ISA = 89@EV::IO::ISA =
332These advanced functions set the minimum block interval when polling for I/O events and the minimum 331These advanced functions set the minimum block interval when polling for I/O events and the minimum
333wait interval for timer events. See the libev documentation at 332wait interval for timer events. See the libev documentation at
334L<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#FUNCTIONS_CONTROLLING_THE_EVENT_LOOP> 333L<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#FUNCTIONS_CONTROLLING_THE_EVENT_LOOP>
335(locally installed as F<EV::libev>) for a more detailed discussion. 334(locally installed as F<EV::libev>) for a more detailed discussion.
336 335
336=item $count = EV::pending_count
337
338=item $count = $loop->pending_count
339
340Returns the number of currently pending watchers.
341
342=item EV::invoke_pending
343
344=item $loop->invoke_pending
345
346Invoke all currently pending watchers.
347
337=back 348=back
338 349
339 350
340=head1 WATCHER OBJECTS 351=head1 WATCHER OBJECTS
341 352
445 456
446=item $previous_state = $w->keepalive ($bool) 457=item $previous_state = $w->keepalive ($bool)
447 458
448Normally, C<EV::loop> will return when there are no active watchers 459Normally, C<EV::loop> will return when there are no active watchers
449(which is a "deadlock" because no progress can be made anymore). This is 460(which is a "deadlock" because no progress can be made anymore). This is
450convinient because it allows you to start your watchers (and your jobs), 461convenient because it allows you to start your watchers (and your jobs),
451call C<EV::loop> once and when it returns you know that all your jobs are 462call C<EV::loop> once and when it returns you know that all your jobs are
452finished (or they forgot to register some watchers for their task :). 463finished (or they forgot to register some watchers for their task :).
453 464
454Sometimes, however, this gets in your way, for example when the module 465Sometimes, however, this gets in your way, for example when the module
455that calls C<EV::loop> (usually the main program) is not the same module 466that calls C<EV::loop> (usually the main program) is not the same module
687 698
688=item $w = EV::signal $signal, $callback 699=item $w = EV::signal $signal, $callback
689 700
690=item $w = EV::signal_ns $signal, $callback 701=item $w = EV::signal_ns $signal, $callback
691 702
703=item $w = $loop->signal ($signal, $callback)
704
705=item $w = $loop->signal_ns ($signal, $callback)
706
692Call the callback when $signal is received (the signal can be specified by 707Call the callback when $signal is received (the signal can be specified by
693number or by name, just as with C<kill> or C<%SIG>). 708number or by name, just as with C<kill> or C<%SIG>).
709
710Only one event loop can grab a given signal - attempting to grab the same
711signal from two EV loops will crash the program immediately or cause data
712corruption.
694 713
695EV will grab the signal for the process (the kernel only allows one 714EV will grab the signal for the process (the kernel only allows one
696component to receive a signal at a time) when you start a signal watcher, 715component to receive a signal at a time) when you start a signal watcher,
697and removes it again when you stop it. Perl does the same when you 716and removes it again when you stop it. Perl does the same when you
698add/remove callbacks to C<%SIG>, so watch out. 717add/remove callbacks to C<%SIG>, so watch out.
1044 1063
1045=back 1064=back
1046 1065
1047=head3 ASYNC WATCHERS - how to wake up another event loop 1066=head3 ASYNC WATCHERS - how to wake up another event loop
1048 1067
1049Async watchers are provided by EV, but have little use in perl directly, as perl 1068Async watchers are provided by EV, but have little use in perl directly,
1050neither supports threads nor direct access to signal handlers or other 1069as perl neither supports threads running in parallel nor direct access to
1051contexts where they could be of value. 1070signal handlers or other contexts where they could be of value.
1052 1071
1053It is, however, possible to use them from the XS level. 1072It is, however, possible to use them from the XS level.
1054 1073
1055Please see the libev documentation for further details. 1074Please see the libev documentation for further details.
1056 1075
1084 my $async_check = EV::check sub { }; 1103 my $async_check = EV::check sub { };
1085 1104
1086This ensures that perl gets into control for a short time to handle any 1105This ensures that perl gets into control for a short time to handle any
1087pending signals, and also ensures (slightly) slower overall operation. 1106pending signals, and also ensures (slightly) slower overall operation.
1088 1107
1089=head1 THREADS 1108=head1 ITHREADS
1090 1109
1091Threads are not supported by this module in any way. Perl pseudo-threads 1110Ithreads are not supported by this module in any way. Perl pseudo-threads
1092is evil stuff and must die. As soon as Perl gains real threads I will work 1111is evil stuff and must die. Real threads as provided by Coro are fully
1093on thread support for it. 1112supported (and enhanced support is available via L<Coro::EV>).
1094 1113
1095=head1 FORK 1114=head1 FORK
1096 1115
1097Most of the "improved" event delivering mechanisms of modern operating 1116Most of the "improved" event delivering mechanisms of modern operating
1098systems have quite a few problems with fork(2) (to put it bluntly: it is 1117systems have quite a few problems with fork(2) (to put it bluntly: it is

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines