… | |
… | |
1909 | ev_unref (EV_P) |
1909 | ev_unref (EV_P) |
1910 | { |
1910 | { |
1911 | --activecnt; |
1911 | --activecnt; |
1912 | } |
1912 | } |
1913 | |
1913 | |
|
|
1914 | void |
|
|
1915 | ev_now_update (EV_P) |
|
|
1916 | { |
|
|
1917 | time_update (EV_A_ 1e100); |
|
|
1918 | } |
|
|
1919 | |
1914 | static int loop_done; |
1920 | static int loop_done; |
1915 | |
1921 | |
1916 | void |
1922 | void |
1917 | ev_loop (EV_P_ int flags) |
1923 | ev_loop (EV_P_ int flags) |
1918 | { |
1924 | { |
… | |
… | |
2827 | ev_loop (EV_A_ EVLOOP_NONBLOCK); |
2833 | ev_loop (EV_A_ EVLOOP_NONBLOCK); |
2828 | } |
2834 | } |
2829 | } |
2835 | } |
2830 | } |
2836 | } |
2831 | |
2837 | |
|
|
2838 | static void |
|
|
2839 | embed_fork_cb (EV_P_ ev_fork *fork_w, int revents) |
|
|
2840 | { |
|
|
2841 | ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); |
|
|
2842 | |
|
|
2843 | { |
|
|
2844 | struct ev_loop *loop = w->other; |
|
|
2845 | |
|
|
2846 | ev_loop_fork (EV_A); |
|
|
2847 | } |
|
|
2848 | } |
|
|
2849 | |
2832 | #if 0 |
2850 | #if 0 |
2833 | static void |
2851 | static void |
2834 | embed_idle_cb (EV_P_ ev_idle *idle, int revents) |
2852 | embed_idle_cb (EV_P_ ev_idle *idle, int revents) |
2835 | { |
2853 | { |
2836 | ev_idle_stop (EV_A_ idle); |
2854 | ev_idle_stop (EV_A_ idle); |
… | |
… | |
2856 | |
2874 | |
2857 | ev_prepare_init (&w->prepare, embed_prepare_cb); |
2875 | ev_prepare_init (&w->prepare, embed_prepare_cb); |
2858 | ev_set_priority (&w->prepare, EV_MINPRI); |
2876 | ev_set_priority (&w->prepare, EV_MINPRI); |
2859 | ev_prepare_start (EV_A_ &w->prepare); |
2877 | ev_prepare_start (EV_A_ &w->prepare); |
2860 | |
2878 | |
|
|
2879 | ev_fork_init (&w->fork, embed_fork_cb); |
|
|
2880 | ev_fork_start (EV_A_ &w->fork); |
|
|
2881 | |
2861 | /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ |
2882 | /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ |
2862 | |
2883 | |
2863 | ev_start (EV_A_ (W)w, 1); |
2884 | ev_start (EV_A_ (W)w, 1); |
2864 | |
2885 | |
2865 | EV_FREQUENT_CHECK; |
2886 | EV_FREQUENT_CHECK; |
… | |
… | |
2872 | if (expect_false (!ev_is_active (w))) |
2893 | if (expect_false (!ev_is_active (w))) |
2873 | return; |
2894 | return; |
2874 | |
2895 | |
2875 | EV_FREQUENT_CHECK; |
2896 | EV_FREQUENT_CHECK; |
2876 | |
2897 | |
2877 | ev_io_stop (EV_A_ &w->io); |
2898 | ev_io_stop (EV_A_ &w->io); |
2878 | ev_prepare_stop (EV_A_ &w->prepare); |
2899 | ev_prepare_stop (EV_A_ &w->prepare); |
2879 | |
2900 | ev_fork_stop (EV_A_ &w->fork); |
2880 | ev_stop (EV_A_ (W)w); |
|
|
2881 | |
2901 | |
2882 | EV_FREQUENT_CHECK; |
2902 | EV_FREQUENT_CHECK; |
2883 | } |
2903 | } |
2884 | #endif |
2904 | #endif |
2885 | |
2905 | |
… | |
… | |
2982 | once_cb (EV_P_ struct ev_once *once, int revents) |
3002 | once_cb (EV_P_ struct ev_once *once, int revents) |
2983 | { |
3003 | { |
2984 | void (*cb)(int revents, void *arg) = once->cb; |
3004 | void (*cb)(int revents, void *arg) = once->cb; |
2985 | void *arg = once->arg; |
3005 | void *arg = once->arg; |
2986 | |
3006 | |
2987 | ev_io_stop (EV_A_ &once->io); |
3007 | ev_io_stop (EV_A_ &once->io); |
2988 | ev_timer_stop (EV_A_ &once->to); |
3008 | ev_timer_stop (EV_A_ &once->to); |
2989 | ev_free (once); |
3009 | ev_free (once); |
2990 | |
3010 | |
2991 | cb (revents, arg); |
3011 | cb (revents, arg); |
2992 | } |
3012 | } |
2993 | |
3013 | |
2994 | static void |
3014 | static void |
2995 | once_cb_io (EV_P_ ev_io *w, int revents) |
3015 | once_cb_io (EV_P_ ev_io *w, int revents) |
2996 | { |
3016 | { |
2997 | once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents); |
3017 | struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)); |
|
|
3018 | |
|
|
3019 | once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to)); |
2998 | } |
3020 | } |
2999 | |
3021 | |
3000 | static void |
3022 | static void |
3001 | once_cb_to (EV_P_ ev_timer *w, int revents) |
3023 | once_cb_to (EV_P_ ev_timer *w, int revents) |
3002 | { |
3024 | { |
3003 | once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents); |
3025 | struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)); |
|
|
3026 | |
|
|
3027 | once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); |
3004 | } |
3028 | } |
3005 | |
3029 | |
3006 | void |
3030 | void |
3007 | ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) |
3031 | ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) |
3008 | { |
3032 | { |