summaryrefslogtreecommitdiff
path: root/ev.pod
diff options
context:
space:
mode:
authorroot <root>2007-11-27 20:38:07 +0000
committerroot <root>2007-11-27 20:38:07 +0000
commitd62943221d916737d52e83db662e6a1e2f92db0a (patch)
treec58823176c724bd60c0aff8583768564cb0ea69d /ev.pod
parente0d2a4b0f08314f5c9f39199ee91f045c2f98d4b (diff)
*** empty log message ***
Diffstat (limited to 'ev.pod')
-rw-r--r--ev.pod35
1 files changed, 32 insertions, 3 deletions
diff --git a/ev.pod b/ev.pod
index 1b797df..cac8de1 100644
--- a/ev.pod
+++ b/ev.pod
@@ -705,7 +705,7 @@ is pending (but not active) you must not call an init function on it (but
C<ev_TYPE_set> is safe) and you must make sure the watcher is available to
libev (e.g. you cnanot C<free ()> it).
-=item callback = ev_cb (ev_TYPE *watcher)
+=item callback ev_cb (ev_TYPE *watcher)
Returns the callback currently set on the watcher.
@@ -743,8 +743,37 @@ can cast it back to your own type:
...
}
-More interesting and less C-conformant ways of catsing your callback type
-have been omitted....
+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:
+
+ struct my_biggy
+ {
+ int some_data;
+ ev_timer t1;
+ ev_timer t2;
+ }
+
+In this case getting the pointer to C<my_biggy> is a bit more complicated,
+you need to use C<offsetof>:
+
+ #include <stddef.h>
+
+ static void
+ t1_cb (EV_P_ struct ev_timer *w, int revents)
+ {
+ struct my_biggy big = (struct my_biggy *
+ (((char *)w) - offsetof (struct my_biggy, t1));
+ }
+
+ static void
+ t2_cb (EV_P_ struct ev_timer *w, int revents)
+ {
+ struct my_biggy big = (struct my_biggy *
+ (((char *)w) - offsetof (struct my_biggy, t2));
+ }
=head1 WATCHER TYPES