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

Comparing EV/EV.pm (file contents):
Revision 1.151 by root, Tue Sep 4 23:14:45 2018 UTC vs.
Revision 1.153 by root, Sun Oct 28 23:51:23 2018 UTC

342| EV::WRITE>, indicating the type of I/O event you want to wait for. If 342| EV::WRITE>, indicating the type of I/O event you want to wait for. If
343you do not want to wait for some I/O event, specify C<undef> for 343you do not want to wait for some I/O event, specify C<undef> for
344C<$fh_or_undef> and C<0> for C<$events>). 344C<$fh_or_undef> and C<0> for C<$events>).
345 345
346If timeout is C<undef> or negative, then there will be no 346If timeout is C<undef> or negative, then there will be no
347timeout. Otherwise a EV::timer with this value will be started. 347timeout. Otherwise an C<EV::timer> with this value will be started.
348 348
349When an error occurs or either the timeout or I/O watcher triggers, then 349When an error occurs or either the timeout or I/O watcher triggers, then
350the callback will be called with the received event set (in general 350the callback will be called with the received event set (in general
351you can expect it to be a combination of C<EV::ERROR>, C<EV::READ>, 351you can expect it to be a combination of C<EV::ERROR>, C<EV::READ>,
352C<EV::WRITE> and C<EV::TIMER>). 352C<EV::WRITE> and C<EV::TIMER>).
710time as second argument. 710time as second argument.
711 711
712I<This callback MUST NOT stop or destroy this or any other periodic 712I<This callback MUST NOT stop or destroy this or any other periodic
713watcher, ever, and MUST NOT call any event loop functions or methods>. If 713watcher, ever, and MUST NOT call any event loop functions or methods>. If
714you need to stop it, return 1e30 and stop it afterwards. You may create 714you need to stop it, return 1e30 and stop it afterwards. You may create
715and start a C<EV::prepare> watcher for this task. 715and start an C<EV::prepare> watcher for this task.
716 716
717It must return the next time to trigger, based on the passed time value 717It must return the next time to trigger, based on the passed time value
718(that is, the lowest time value larger than or equal to to the second 718(that is, the lowest time value larger than or equal to to the second
719argument). It will usually be called just before the callback will be 719argument). It will usually be called just before the callback will be
720triggered, but might be called at other times, too. 720triggered, but might be called at other times, too.
721 721
722This can be used to create very complex timers, such as a timer that 722This can be used to create very complex timers, such as a timer that
723triggers on each midnight, local time (actually 24 hours after the last 723triggers on each midnight, local time (actually one day after the last
724midnight, to keep the example simple. If you know a way to do it correctly 724midnight, to keep the example simple):
725in about the same space (without requiring elaborate modules), drop me a
726note :):
727 725
728 my $daily = EV::periodic 0, 0, sub { 726 my $daily = EV::periodic 0, 0, sub {
729 my ($w, $now) = @_; 727 my ($w, $now) = @_;
730 728
731 use Time::Local (); 729 use Time::Local ();
732 my (undef, undef, undef, $d, $m, $y) = localtime $now; 730 my (undef, undef, undef, $d, $m, $y) = localtime $now;
733 86400 + Time::Local::timelocal 0, 0, 0, $d, $m, $y 731 Time::Local::timelocal_nocheck 0, 0, 0, $d + 1, $m, $y
734 }, sub { 732 }, sub {
735 print "it's midnight or likely shortly after, now\n"; 733 print "it's midnight or likely shortly after, now\n";
736 }; 734 };
737 735
738=back 736=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines