From c49b0fe38ca566c4494ba31d46ba2015124ae098 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Sep 2008 18:25:50 +0000 Subject: *** empty log message *** --- ev.pod | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'ev.pod') diff --git a/ev.pod b/ev.pod index 1c6c94a..55c78b0 100644 --- a/ev.pod +++ b/ev.pod @@ -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 is a bit more complicated, -you need to use C: +In this case getting the pointer to C is a bit more +complicated: Either you store the address of your C struct +in the C member of the watcher, or you need to use some pointer +arithmetic using C inside your watchers: #include -- cgit v1.2.3