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

Comparing libev/ev.pod (file contents):
Revision 1.19 by root, Mon Nov 12 09:02:16 2007 UTC vs.
Revision 1.20 by root, Mon Nov 12 09:06:09 2007 UTC

677=back 677=back
678 678
679=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
680 680
681Prepare and check watchers are usually (but not always) used in tandem: 681Prepare and check watchers are usually (but not always) used in tandem:
682Prepare watchers get invoked before the process blocks and check watchers 682prepare watchers get invoked before the process blocks and check watchers
683afterwards. 683afterwards.
684 684
685Their main purpose is to integrate other event mechanisms into libev. This 685Their main purpose is to integrate other event mechanisms into libev. This
686could be used, for example, to track variable changes, implement your own 686could be used, for example, to track variable changes, implement your own
687watchers, integrate net-snmp or a coroutine library and lots more. 687watchers, integrate net-snmp or a coroutine library and lots more.
690to 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
691them 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
692provide just this functionality). Then, in the check watcher you check for 692provide just this functionality). Then, in the check watcher you check for
693any events that occured (by checking the pending status of all watchers 693any events that occured (by checking the pending status of all watchers
694and 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
695callbacks will never actually be called (but must be valid neverthelles, 695callbacks will never actually be called (but must be valid nevertheless,
696because you never know, you know?). 696because you never know, you know?).
697 697
698As another example, the Perl Coro module uses these hooks to integrate 698As another example, the Perl Coro module uses these hooks to integrate
699coroutines into libev programs, by yielding to other active coroutines 699coroutines into libev programs, by yielding to other active coroutines
700during each prepare and only letting the process block if no coroutines 700during each prepare and only letting the process block if no coroutines
701are ready to run (its actually more complicated, it only runs coroutines 701are ready to run (it's actually more complicated: it only runs coroutines
702with priority higher than the event loop and one lower priority once, 702with priority higher than or equal to the event loop and one coroutine
703using 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
704coroutines exist, thus mapping low-priority coroutines to idle/background 704loop from blocking if lower-priority coroutines are active, thus mapping
705tasks). 705low-priority coroutines to idle/background tasks).
706 706
707=over 4 707=over 4
708 708
709=item ev_prepare_init (ev_prepare *, callback) 709=item ev_prepare_init (ev_prepare *, callback)
710 710
769 769
770Feed 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!).
771 771
772=back 772=back
773 773
774=head1 LIBEVENT EMULATION
775
776TBD.
777
778=head1 C++ SUPPORT
779
780TBD.
781
774=head1 AUTHOR 782=head1 AUTHOR
775 783
776Marc Lehmann <libev@schmorp.de>. 784Marc Lehmann <libev@schmorp.de>.
777 785

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines