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

Comparing libev/ev.3 (file contents):
Revision 1.28 by root, Tue Nov 27 20:26:50 2007 UTC vs.
Revision 1.29 by root, Tue Nov 27 20:38:07 2007 UTC

856Returns a true value iff the watcher is pending, (i.e. it has outstanding 856Returns a true value iff the watcher is pending, (i.e. it has outstanding
857events but its callback has not yet been invoked). As long as a watcher 857events but its callback has not yet been invoked). As long as a watcher
858is pending (but not active) you must not call an init function on it (but 858is pending (but not active) you must not call an init function on it (but
859\&\f(CW\*(C`ev_TYPE_set\*(C'\fR is safe) and you must make sure the watcher is available to 859\&\f(CW\*(C`ev_TYPE_set\*(C'\fR is safe) and you must make sure the watcher is available to
860libev (e.g. you cnanot \f(CW\*(C`free ()\*(C'\fR it). 860libev (e.g. you cnanot \f(CW\*(C`free ()\*(C'\fR it).
861.IP "callback = ev_cb (ev_TYPE *watcher)" 4 861.IP "callback ev_cb (ev_TYPE *watcher)" 4
862.IX Item "callback = ev_cb (ev_TYPE *watcher)" 862.IX Item "callback ev_cb (ev_TYPE *watcher)"
863Returns the callback currently set on the watcher. 863Returns the callback currently set on the watcher.
864.IP "ev_cb_set (ev_TYPE *watcher, callback)" 4 864.IP "ev_cb_set (ev_TYPE *watcher, callback)" 4
865.IX Item "ev_cb_set (ev_TYPE *watcher, callback)" 865.IX Item "ev_cb_set (ev_TYPE *watcher, callback)"
866Change the callback. You can change the callback at virtually any time 866Change the callback. You can change the callback at virtually any time
867(modulo threads). 867(modulo threads).
893\& struct my_io *w = (struct my_io *)w_; 893\& struct my_io *w = (struct my_io *)w_;
894\& ... 894\& ...
895\& } 895\& }
896.Ve 896.Ve
897.PP 897.PP
898More interesting and less C\-conformant ways of catsing your callback type 898More interesting and less C\-conformant ways of casting your callback type
899have been omitted.... 899instead have been omitted.
900.PP
901Another common scenario is having some data structure with multiple
902watchers:
903.PP
904.Vb 6
905\& struct my_biggy
906\& {
907\& int some_data;
908\& ev_timer t1;
909\& ev_timer t2;
910\& }
911.Ve
912.PP
913In this case getting the pointer to \f(CW\*(C`my_biggy\*(C'\fR is a bit more complicated,
914you need to use \f(CW\*(C`offsetof\*(C'\fR:
915.PP
916.Vb 1
917\& #include <stddef.h>
918.Ve
919.PP
920.Vb 6
921\& static void
922\& t1_cb (EV_P_ struct ev_timer *w, int revents)
923\& {
924\& struct my_biggy big = (struct my_biggy *
925\& (((char *)w) - offsetof (struct my_biggy, t1));
926\& }
927.Ve
928.PP
929.Vb 6
930\& static void
931\& t2_cb (EV_P_ struct ev_timer *w, int revents)
932\& {
933\& struct my_biggy big = (struct my_biggy *
934\& (((char *)w) - offsetof (struct my_biggy, t2));
935\& }
936.Ve
900.SH "WATCHER TYPES" 937.SH "WATCHER TYPES"
901.IX Header "WATCHER TYPES" 938.IX Header "WATCHER TYPES"
902This section describes each watcher in detail, but will not repeat 939This section describes each watcher in detail, but will not repeat
903information given in the last section. Any initialisation/set macros, 940information given in the last section. Any initialisation/set macros,
904functions and members specific to the watcher type are explained. 941functions and members specific to the watcher type are explained.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines