… | |
… | |
2123 | Example: Call a callback every hour, or, more precisely, whenever the |
2123 | Example: Call a callback every hour, or, more precisely, whenever the |
2124 | system time is divisible by 3600. The callback invocation times have |
2124 | system time is divisible by 3600. The callback invocation times have |
2125 | potentially a lot of jitter, but good long-term stability. |
2125 | potentially a lot of jitter, but good long-term stability. |
2126 | |
2126 | |
2127 | static void |
2127 | static void |
2128 | clock_cb (struct ev_loop *loop, ev_io *w, int revents) |
2128 | clock_cb (struct ev_loop *loop, ev_periodic *w, int revents) |
2129 | { |
2129 | { |
2130 | ... its now a full hour (UTC, or TAI or whatever your clock follows) |
2130 | ... its now a full hour (UTC, or TAI or whatever your clock follows) |
2131 | } |
2131 | } |
2132 | |
2132 | |
2133 | ev_periodic hourly_tick; |
2133 | ev_periodic hourly_tick; |
… | |
… | |
4042 | will be C<0>. |
4042 | will be C<0>. |
4043 | |
4043 | |
4044 | =item EV_COMMON |
4044 | =item EV_COMMON |
4045 | |
4045 | |
4046 | By default, all watchers have a C<void *data> member. By redefining |
4046 | By default, all watchers have a C<void *data> member. By redefining |
4047 | this macro to a something else you can include more and other types of |
4047 | this macro to something else you can include more and other types of |
4048 | members. You have to define it each time you include one of the files, |
4048 | members. You have to define it each time you include one of the files, |
4049 | though, and it must be identical each time. |
4049 | though, and it must be identical each time. |
4050 | |
4050 | |
4051 | For example, the perl EV module uses something like this: |
4051 | For example, the perl EV module uses something like this: |
4052 | |
4052 | |
… | |
… | |
4351 | maintainable. |
4351 | maintainable. |
4352 | |
4352 | |
4353 | And of course, some compiler warnings are just plain stupid, or simply |
4353 | And of course, some compiler warnings are just plain stupid, or simply |
4354 | wrong (because they don't actually warn about the condition their message |
4354 | wrong (because they don't actually warn about the condition their message |
4355 | seems to warn about). For example, certain older gcc versions had some |
4355 | seems to warn about). For example, certain older gcc versions had some |
4356 | warnings that resulted an extreme number of false positives. These have |
4356 | warnings that resulted in an extreme number of false positives. These have |
4357 | been fixed, but some people still insist on making code warn-free with |
4357 | been fixed, but some people still insist on making code warn-free with |
4358 | such buggy versions. |
4358 | such buggy versions. |
4359 | |
4359 | |
4360 | While libev is written to generate as few warnings as possible, |
4360 | While libev is written to generate as few warnings as possible, |
4361 | "warn-free" code is not a goal, and it is recommended not to build libev |
4361 | "warn-free" code is not a goal, and it is recommended not to build libev |