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

Comparing EV/EV.pm (file contents):
Revision 1.56 by root, Tue Nov 27 10:59:10 2007 UTC vs.
Revision 1.61 by root, Thu Dec 6 03:13:07 2007 UTC

67package EV; 67package EV;
68 68
69use strict; 69use strict;
70 70
71BEGIN { 71BEGIN {
72 our $VERSION = '1.4'; 72 our $VERSION = '1.6';
73 use XSLoader; 73 use XSLoader;
74 XSLoader::load "EV", $VERSION; 74 XSLoader::load "EV", $VERSION;
75} 75}
76 76
77@EV::IO::ISA = 77@EV::IO::ISA =
131innermost call to EV::loop return. 131innermost call to EV::loop return.
132 132
133When called with an argument of EV::UNLOOP_ALL, all calls to EV::loop will return as 133When called with an argument of EV::UNLOOP_ALL, all calls to EV::loop will return as
134fast as possible. 134fast as possible.
135 135
136=item $count = EV::loop_count
137
138Return the number of times the event loop has polled for new
139events. Sometiems useful as a generation counter.
140
136=item EV::once $fh_or_undef, $events, $timeout, $cb->($revents) 141=item EV::once $fh_or_undef, $events, $timeout, $cb->($revents)
137 142
138This function rolls together an I/O and a timer watcher for a single 143This function rolls together an I/O and a timer watcher for a single
139one-shot event without the need for managing a watcher object. 144one-shot event without the need for managing a watcher object.
140 145
576as even with OS-supported change notifications, this can be 581as even with OS-supported change notifications, this can be
577resource-intensive. 582resource-intensive.
578 583
579The C<stat_ns> variant doesn't start (activate) the newly created watcher. 584The C<stat_ns> variant doesn't start (activate) the newly created watcher.
580 585
586=item ... = $w->stat
587
588This call is very similar to the perl C<stat> built-in: It stats (using
589C<lstat>) the path specified in the watcher and sets perls stat cache (as
590well as EV's idea of the current stat values) to the values found.
591
592In scalar context, a boolean is return indicating success or failure of
593the stat. In list context, the same 13-value list as with stat is returned
594(except that the blksize and blocks fields are not reliable).
595
596In the case of an error, errno is set to C<ENOENT> (regardless of the
597actual error value) and the C<nlink> value is forced to zero (if the stat
598was successful then nlink is guaranteed to be non-zero).
599
600See also the next two entries for more info.
601
602=item ... = $w->attr
603
604Just like C<< $w->stat >>, but without the initial stat'ing: this returns
605the values most recently detected by EV. See the next entry for more info.
606
607=item ... = $w->prev
608
609Just like C<< $w->stat >>, but without the initial stat'ing: this returns
610the previous set of values, before the change.
611
612That is, when the watcher callback is invoked, C<< $w->prev >> will be set
613to the values found I<before> a change was detected, while C<< $w->attr >>
614returns the values found leading to the change detection. The difference (if any)
615between C<prev> and C<attr> is what triggered the callback.
616
617If you did something to the filesystem object and do not want to trigger
618yet another change, you can call C<stat> to update EV's idea of what the
619current attributes are.
620
581=item $w->set ($path, $interval) 621=item $w->set ($path, $interval)
582 622
583Reconfigures the watcher, see the constructor above for details. Can be 623Reconfigures the watcher, see the constructor above for details. Can be
584called at any time. 624called at any time.
585 625
712 752
713The C<fork_ns> variant doesn't start (activate) the newly created watcher. 753The C<fork_ns> variant doesn't start (activate) the newly created watcher.
714 754
715=back 755=back
716 756
757
758=head1 PERL SIGNALS
759
760While Perl signal handling (C<%SIG>) is not affected by EV, the behaviour
761with EV is as the same as any other C library: Perl-signals will only be
762handled when Perl runs, which means your signal handler might be invoked
763only the next time an event callback is invoked.
764
765The solution is to use EV signal watchers (see C<EV::signal>), which will
766ensure proper operations with regards to other event watchers.
767
768If you cannot do this for whatever reason, you can also force a watcher
769to be called on every event loop iteration by installing a C<EV::check>
770watcher:
771
772 my $async_check = EV::check sub { };
773
774This ensures that perl shortly gets into control for a short time, and
775also ensures slower overall operation.
717 776
718=head1 THREADS 777=head1 THREADS
719 778
720Threads are not supported by this module in any way. Perl pseudo-threads 779Threads are not supported by this module in any way. Perl pseudo-threads
721is evil stuff and must die. As soon as Perl gains real threads I will work 780is evil stuff and must die. As soon as Perl gains real threads I will work
749 808
7501; 8091;
751 810
752=head1 SEE ALSO 811=head1 SEE ALSO
753 812
754L<EV::DNS>. 813L<EV::ADNS> (asynchronous dns), L<Glib::EV> (makes Glib/Gtk2 use EV as
814event loop), L<Coro::EV> (efficient coroutines with EV).
755 815
756=head1 AUTHOR 816=head1 AUTHOR
757 817
758 Marc Lehmann <schmorp@schmorp.de> 818 Marc Lehmann <schmorp@schmorp.de>
759 http://home.schmorp.de/ 819 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines