… | |
… | |
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; |
… | |
… | |
3885 | EV_PREPARE_ENABLE, EV_CHECK_ENABLE, EV_FORK_ENABLE, EV_SIGNAL_ENABLE, |
3885 | EV_PREPARE_ENABLE, EV_CHECK_ENABLE, EV_FORK_ENABLE, EV_SIGNAL_ENABLE, |
3886 | EV_ASYNC_ENABLE, EV_CHILD_ENABLE. |
3886 | EV_ASYNC_ENABLE, EV_CHILD_ENABLE. |
3887 | |
3887 | |
3888 | If undefined or defined to be C<1> (and the platform supports it), then |
3888 | If undefined or defined to be C<1> (and the platform supports it), then |
3889 | the respective watcher type is supported. If defined to be C<0>, then it |
3889 | the respective watcher type is supported. If defined to be C<0>, then it |
3890 | is not. Disabling watcher types mainly saves codesize. |
3890 | is not. Disabling watcher types mainly saves code size. |
3891 | |
3891 | |
3892 | =item EV_FEATURES |
3892 | =item EV_FEATURES |
3893 | |
3893 | |
3894 | If you need to shave off some kilobytes of code at the expense of some |
3894 | If you need to shave off some kilobytes of code at the expense of some |
3895 | speed (but with the full API), you can define this symbol to request |
3895 | speed (but with the full API), you can define this symbol to request |
… | |
… | |
3915 | |
3915 | |
3916 | =item C<1> - faster/larger code |
3916 | =item C<1> - faster/larger code |
3917 | |
3917 | |
3918 | Use larger code to speed up some operations. |
3918 | Use larger code to speed up some operations. |
3919 | |
3919 | |
3920 | Currently this is used to override some inlining decisions (enlarging the roughly |
3920 | Currently this is used to override some inlining decisions (enlarging the |
3921 | 30% code size on amd64. |
3921 | code size by roughly 30% on amd64). |
3922 | |
3922 | |
3923 | When optimising for size, use of compiler flags such as C<-Os> with |
3923 | When optimising for size, use of compiler flags such as C<-Os> with |
3924 | gcc recommended, as well as C<-DNDEBUG>, as libev contains a number of |
3924 | gcc is recommended, as well as C<-DNDEBUG>, as libev contains a number of |
3925 | assertions. |
3925 | assertions. |
3926 | |
3926 | |
3927 | =item C<2> - faster/larger data structures |
3927 | =item C<2> - faster/larger data structures |
3928 | |
3928 | |
3929 | Replaces the small 2-heap for timer management by a faster 4-heap, larger |
3929 | Replaces the small 2-heap for timer management by a faster 4-heap, larger |
3930 | hash table sizes and so on. This will usually further increase codesize |
3930 | hash table sizes and so on. This will usually further increase code size |
3931 | and can additionally have an effect on the size of data structures at |
3931 | and can additionally have an effect on the size of data structures at |
3932 | runtime. |
3932 | runtime. |
3933 | |
3933 | |
3934 | =item C<4> - full API configuration |
3934 | =item C<4> - full API configuration |
3935 | |
3935 | |
… | |
… | |
3972 | I/O watcher then might come out at only 5Kb. |
3972 | I/O watcher then might come out at only 5Kb. |
3973 | |
3973 | |
3974 | =item EV_AVOID_STDIO |
3974 | =item EV_AVOID_STDIO |
3975 | |
3975 | |
3976 | If this is set to C<1> at compiletime, then libev will avoid using stdio |
3976 | If this is set to C<1> at compiletime, then libev will avoid using stdio |
3977 | functions (printf, scanf, perror etc.). This will increase the codesize |
3977 | functions (printf, scanf, perror etc.). This will increase the code size |
3978 | somewhat, but if your program doesn't otherwise depend on stdio and your |
3978 | somewhat, but if your program doesn't otherwise depend on stdio and your |
3979 | libc allows it, this avoids linking in the stdio library which is quite |
3979 | libc allows it, this avoids linking in the stdio library which is quite |
3980 | big. |
3980 | big. |
3981 | |
3981 | |
3982 | Note that error messages might become less precise when this option is |
3982 | Note that error messages might become less precise when this option is |
… | |
… | |
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 |