ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.18 by root, Mon Nov 12 09:01:12 2007 UTC vs.
Revision 1.21 by root, Mon Nov 12 09:07:10 2007 UTC

582(that is, the lowest time value larger than to the second argument). It 582(that is, the lowest time value larger than to the second argument). It
583will usually be called just before the callback will be triggered, but 583will usually be called just before the callback will be triggered, but
584might be called at other times, too. 584might be called at other times, too.
585 585
586NOTE: I<< This callback must always return a time that is later than the 586NOTE: I<< This callback must always return a time that is later than the
587passed C<now> value >>. Not even C<now> itself will do, it must be larger. 587passed C<now> value >>. Not even C<now> itself will do, it I<must> be larger.
588 588
589This can be used to create very complex timers, such as a timer that 589This can be used to create very complex timers, such as a timer that
590triggers on each midnight, local time. To do this, you would calculate the 590triggers on each midnight, local time. To do this, you would calculate the
591next midnight after C<now> and return the timestamp value for this. How you do this 591next midnight after C<now> and return the timestamp value for this. How
592is, again, up to you (but it is not trivial). 592you do this is, again, up to you (but it is not trivial, which is the main
593reason I omitted it as an example).
593 594
594=back 595=back
595 596
596=item ev_periodic_again (loop, ev_periodic *) 597=item ev_periodic_again (loop, ev_periodic *)
597 598
676=back 677=back
677 678
678=head2 C<ev_prepare> and C<ev_check> - customise your event loop 679=head2 C<ev_prepare> and C<ev_check> - customise your event loop
679 680
680Prepare and check watchers are usually (but not always) used in tandem: 681Prepare and check watchers are usually (but not always) used in tandem:
681Prepare watchers get invoked before the process blocks and check watchers 682prepare watchers get invoked before the process blocks and check watchers
682afterwards. 683afterwards.
683 684
684Their main purpose is to integrate other event mechanisms into libev. This 685Their main purpose is to integrate other event mechanisms into libev. This
685could be used, for example, to track variable changes, implement your own 686could be used, for example, to track variable changes, implement your own
686watchers, integrate net-snmp or a coroutine library and lots more. 687watchers, integrate net-snmp or a coroutine library and lots more.
689to be watched by the other library, registering C<ev_io> watchers for 690to be watched by the other library, registering C<ev_io> watchers for
690them and starting an C<ev_timer> watcher for any timeouts (many libraries 691them and starting an C<ev_timer> watcher for any timeouts (many libraries
691provide just this functionality). Then, in the check watcher you check for 692provide just this functionality). Then, in the check watcher you check for
692any events that occured (by checking the pending status of all watchers 693any events that occured (by checking the pending status of all watchers
693and stopping them) and call back into the library. The I/O and timer 694and stopping them) and call back into the library. The I/O and timer
694callbacks will never actually be called (but must be valid neverthelles, 695callbacks will never actually be called (but must be valid nevertheless,
695because you never know, you know?). 696because you never know, you know?).
696 697
697As another example, the Perl Coro module uses these hooks to integrate 698As another example, the Perl Coro module uses these hooks to integrate
698coroutines into libev programs, by yielding to other active coroutines 699coroutines into libev programs, by yielding to other active coroutines
699during each prepare and only letting the process block if no coroutines 700during each prepare and only letting the process block if no coroutines
700are ready to run (its actually more complicated, it only runs coroutines 701are ready to run (it's actually more complicated: it only runs coroutines
701with priority higher than the event loop and one lower priority once, 702with priority higher than or equal to the event loop and one coroutine
702using idle watchers to keep the event loop from blocking if lower-priority 703of lower priority, but only once, using idle watchers to keep the event
703coroutines exist, thus mapping low-priority coroutines to idle/background 704loop from blocking if lower-priority coroutines are active, thus mapping
704tasks). 705low-priority coroutines to idle/background tasks).
705 706
706=over 4 707=over 4
707 708
708=item ev_prepare_init (ev_prepare *, callback) 709=item ev_prepare_init (ev_prepare *, callback)
709 710
737started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and 738started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and
738repeat = 0) will be started. While C<0> is a valid timeout, it is of 739repeat = 0) will be started. While C<0> is a valid timeout, it is of
739dubious value. 740dubious value.
740 741
741The callback has the type C<void (*cb)(int revents, void *arg)> and gets 742The callback has the type C<void (*cb)(int revents, void *arg)> and gets
742passed an events set like normal event callbacks (with a combination of 743passed an C<revents> set like normal event callbacks (a combination of
743C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg> 744C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg>
744value passed to C<ev_once>: 745value passed to C<ev_once>:
745 746
746 static void stdin_ready (int revents, void *arg) 747 static void stdin_ready (int revents, void *arg)
747 { 748 {
768 769
769Feed an event as if the given signal occured (loop must be the default loop!). 770Feed an event as if the given signal occured (loop must be the default loop!).
770 771
771=back 772=back
772 773
774=head1 LIBEVENT EMULATION
775
776TBD.
777
778=head1 C++ SUPPORT
779
780TBD.
781
773=head1 AUTHOR 782=head1 AUTHOR
774 783
775Marc Lehmann <libev@schmorp.de>. 784Marc Lehmann <libev@schmorp.de>.
776 785

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines