diff options
| author | root <root> | 2008-09-13 18:25:50 +0000 | 
|---|---|---|
| committer | root <root> | 2008-09-13 18:25:50 +0000 | 
| commit | c49b0fe38ca566c4494ba31d46ba2015124ae098 (patch) | |
| tree | 584625e6222ad26a6ed31ff6631e0feec8372653 | |
| parent | dafe1af050d0634b467b94369ffc99b239a59fe6 (diff) | |
*** empty log message ***
| -rw-r--r-- | Changes | 1 | ||||
| -rw-r--r-- | ev.pod | 16 | 
2 files changed, 12 insertions, 5 deletions
| @@ -4,6 +4,7 @@ WISH? monotonic clocks times/GetTickCount for coarse corrections?  3.44  	- new function: ev_now_update (loop).  	- verify_watcher was not marked static. +        - improve the "associating..." manpage section.  3.43 Sun Jul  6 05:34:41 CEST 2008  	- include more include files on windows to get struct _stati64 @@ -1008,7 +1008,11 @@ data:       int otherfd;       void *somedata;       struct whatever *mostinteresting; -   } +   }; + +   ... +   struct my_io w; +   ev_io_init (&w.io, my_cb, fd, EV_READ);  And since your callback will be called with a pointer to the watcher, you  can cast it back to your own type: @@ -1022,8 +1026,8 @@ can cast it back to your own type:  More interesting and less C-conformant ways of casting your callback type  instead have been omitted. -Another common scenario is having some data structure with multiple -watchers: +Another common scenario is to use some data structure with multiple +embedded watchers:     struct my_biggy     { @@ -1032,8 +1036,10 @@ watchers:       ev_timer t2;     } -In this case getting the pointer to C<my_biggy> is a bit more complicated, -you need to use C<offsetof>: +In this case getting the pointer to C<my_biggy> is a bit more +complicated: Either you store the address of your C<my_biggy> struct +in the C<data> member of the watcher, or you need to use some pointer +arithmetic using C<offsetof> inside your watchers:     #include <stddef.h> | 
