From d62943221d916737d52e83db662e6a1e2f92db0a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Nov 2007 20:38:07 +0000 Subject: *** empty log message *** --- ev.pod | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'ev.pod') 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 is safe) and you must make sure the watcher is available to libev (e.g. you cnanot C 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 is a bit more complicated, +you need to use C: + + #include + + 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 -- cgit v1.2.3