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

Comparing libev/ev.pod (file contents):
Revision 1.54 by root, Tue Nov 27 20:26:51 2007 UTC vs.
Revision 1.56 by root, Wed Nov 28 11:15:55 2007 UTC

703events but its callback has not yet been invoked). As long as a watcher 703events but its callback has not yet been invoked). As long as a watcher
704is pending (but not active) you must not call an init function on it (but 704is pending (but not active) you must not call an init function on it (but
705C<ev_TYPE_set> is safe) and you must make sure the watcher is available to 705C<ev_TYPE_set> is safe) and you must make sure the watcher is available to
706libev (e.g. you cnanot C<free ()> it). 706libev (e.g. you cnanot C<free ()> it).
707 707
708=item callback = ev_cb (ev_TYPE *watcher) 708=item callback ev_cb (ev_TYPE *watcher)
709 709
710Returns the callback currently set on the watcher. 710Returns the callback currently set on the watcher.
711 711
712=item ev_cb_set (ev_TYPE *watcher, callback) 712=item ev_cb_set (ev_TYPE *watcher, callback)
713 713
741 { 741 {
742 struct my_io *w = (struct my_io *)w_; 742 struct my_io *w = (struct my_io *)w_;
743 ... 743 ...
744 } 744 }
745 745
746More interesting and less C-conformant ways of catsing your callback type 746More interesting and less C-conformant ways of casting your callback type
747have been omitted.... 747instead have been omitted.
748
749Another common scenario is having some data structure with multiple
750watchers:
751
752 struct my_biggy
753 {
754 int some_data;
755 ev_timer t1;
756 ev_timer t2;
757 }
758
759In this case getting the pointer to C<my_biggy> is a bit more complicated,
760you need to use C<offsetof>:
761
762 #include <stddef.h>
763
764 static void
765 t1_cb (EV_P_ struct ev_timer *w, int revents)
766 {
767 struct my_biggy big = (struct my_biggy *
768 (((char *)w) - offsetof (struct my_biggy, t1));
769 }
770
771 static void
772 t2_cb (EV_P_ struct ev_timer *w, int revents)
773 {
774 struct my_biggy big = (struct my_biggy *
775 (((char *)w) - offsetof (struct my_biggy, t2));
776 }
748 777
749 778
750=head1 WATCHER TYPES 779=head1 WATCHER TYPES
751 780
752This section describes each watcher in detail, but will not repeat 781This section describes each watcher in detail, but will not repeat
1985 2014
1986=item EV_USE_DEVPOLL 2015=item EV_USE_DEVPOLL
1987 2016
1988reserved for future expansion, works like the USE symbols above. 2017reserved for future expansion, works like the USE symbols above.
1989 2018
2019=item EV_USE_INOTIFY
2020
2021If defined to be C<1>, libev will compile in support for the Linux inotify
2022interface to speed up C<ev_stat> watchers. Its actual availability will
2023be detected at runtime.
2024
1990=item EV_H 2025=item EV_H
1991 2026
1992The name of the F<ev.h> header file used to include it. The default if 2027The name of the F<ev.h> header file used to include it. The default if
1993undefined is C<< <ev.h> >> in F<event.h> and C<"ev.h"> in F<ev.c>. This 2028undefined is C<< <ev.h> >> in F<event.h> and C<"ev.h"> in F<ev.c>. This
1994can be used to virtually rename the F<ev.h> header file in case of conflicts. 2029can be used to virtually rename the F<ev.h> header file in case of conflicts.
2049=item EV_PID_HASHSIZE 2084=item EV_PID_HASHSIZE
2050 2085
2051C<ev_child> watchers use a small hash table to distribute workload by 2086C<ev_child> watchers use a small hash table to distribute workload by
2052pid. The default size is C<16> (or C<1> with C<EV_MINIMAL>), usually more 2087pid. The default size is C<16> (or C<1> with C<EV_MINIMAL>), usually more
2053than enough. If you need to manage thousands of children you might want to 2088than enough. If you need to manage thousands of children you might want to
2054increase this value. 2089increase this value (I<must> be a power of two).
2090
2091=item EV_INOTIFY_HASHSIZE
2092
2093C<ev_staz> watchers use a small hash table to distribute workload by
2094inotify watch id. The default size is C<16> (or C<1> with C<EV_MINIMAL>),
2095usually more than enough. If you need to manage thousands of C<ev_stat>
2096watchers you might want to increase this value (I<must> be a power of
2097two).
2055 2098
2056=item EV_COMMON 2099=item EV_COMMON
2057 2100
2058By default, all watchers have a C<void *data> member. By redefining 2101By default, all watchers have a C<void *data> member. By redefining
2059this macro to a something else you can include more and other types of 2102this macro to a something else you can include more and other types of
2119 2162
2120=item Starting io/check/prepare/idle/signal/child watchers: O(1) 2163=item Starting io/check/prepare/idle/signal/child watchers: O(1)
2121 2164
2122=item Stopping check/prepare/idle watchers: O(1) 2165=item Stopping check/prepare/idle watchers: O(1)
2123 2166
2124=item Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % 16)) 2167=item Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))
2125 2168
2126=item Finding the next timer per loop iteration: O(1) 2169=item Finding the next timer per loop iteration: O(1)
2127 2170
2128=item Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd) 2171=item Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)
2129 2172

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines