ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.256 by root, Thu Jun 19 06:53:49 2008 UTC vs.
Revision 1.263 by root, Wed Oct 1 18:50:03 2008 UTC

287# endif 287# endif
288#endif 288#endif
289 289
290#if EV_USE_INOTIFY 290#if EV_USE_INOTIFY
291# include <sys/inotify.h> 291# include <sys/inotify.h>
292/* some very old inotify.h headers don't have IN_DONT_FOLLOW */
293# ifndef IN_DONT_FOLLOW
294# undef EV_USE_INOTIFY
295# define EV_USE_INOTIFY 0
296# endif
292#endif 297#endif
293 298
294#if EV_SELECT_IS_WINSOCKET 299#if EV_SELECT_IS_WINSOCKET
295# include <winsock.h> 300# include <winsock.h>
296#endif 301#endif
565 struct timeval tv; 570 struct timeval tv;
566 571
567 tv.tv_sec = (time_t)delay; 572 tv.tv_sec = (time_t)delay;
568 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); 573 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
569 574
575 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
576 /* somehting nto guaranteed by newer posix versions, but guaranteed */
577 /* by older ones */
570 select (0, 0, 0, 0, &tv); 578 select (0, 0, 0, 0, &tv);
571#endif 579#endif
572 } 580 }
573} 581}
574 582
1508{ 1516{
1509 postfork = 1; /* must be in line with ev_default_fork */ 1517 postfork = 1; /* must be in line with ev_default_fork */
1510} 1518}
1511 1519
1512#if EV_VERIFY 1520#if EV_VERIFY
1513void noinline 1521static void noinline
1514verify_watcher (EV_P_ W w) 1522verify_watcher (EV_P_ W w)
1515{ 1523{
1516 assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); 1524 assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
1517 1525
1518 if (w->pending) 1526 if (w->pending)
1904 1912
1905void 1913void
1906ev_unref (EV_P) 1914ev_unref (EV_P)
1907{ 1915{
1908 --activecnt; 1916 --activecnt;
1917}
1918
1919void
1920ev_now_update (EV_P)
1921{
1922 time_update (EV_A_ 1e100);
1909} 1923}
1910 1924
1911static int loop_done; 1925static int loop_done;
1912 1926
1913void 1927void
2824 ev_loop (EV_A_ EVLOOP_NONBLOCK); 2838 ev_loop (EV_A_ EVLOOP_NONBLOCK);
2825 } 2839 }
2826 } 2840 }
2827} 2841}
2828 2842
2843static void
2844embed_fork_cb (EV_P_ ev_fork *fork_w, int revents)
2845{
2846 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork));
2847
2848 {
2849 struct ev_loop *loop = w->other;
2850
2851 ev_loop_fork (EV_A);
2852 }
2853}
2854
2829#if 0 2855#if 0
2830static void 2856static void
2831embed_idle_cb (EV_P_ ev_idle *idle, int revents) 2857embed_idle_cb (EV_P_ ev_idle *idle, int revents)
2832{ 2858{
2833 ev_idle_stop (EV_A_ idle); 2859 ev_idle_stop (EV_A_ idle);
2853 2879
2854 ev_prepare_init (&w->prepare, embed_prepare_cb); 2880 ev_prepare_init (&w->prepare, embed_prepare_cb);
2855 ev_set_priority (&w->prepare, EV_MINPRI); 2881 ev_set_priority (&w->prepare, EV_MINPRI);
2856 ev_prepare_start (EV_A_ &w->prepare); 2882 ev_prepare_start (EV_A_ &w->prepare);
2857 2883
2884 ev_fork_init (&w->fork, embed_fork_cb);
2885 ev_fork_start (EV_A_ &w->fork);
2886
2858 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ 2887 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/
2859 2888
2860 ev_start (EV_A_ (W)w, 1); 2889 ev_start (EV_A_ (W)w, 1);
2861 2890
2862 EV_FREQUENT_CHECK; 2891 EV_FREQUENT_CHECK;
2869 if (expect_false (!ev_is_active (w))) 2898 if (expect_false (!ev_is_active (w)))
2870 return; 2899 return;
2871 2900
2872 EV_FREQUENT_CHECK; 2901 EV_FREQUENT_CHECK;
2873 2902
2874 ev_io_stop (EV_A_ &w->io); 2903 ev_io_stop (EV_A_ &w->io);
2875 ev_prepare_stop (EV_A_ &w->prepare); 2904 ev_prepare_stop (EV_A_ &w->prepare);
2876 2905 ev_fork_stop (EV_A_ &w->fork);
2877 ev_stop (EV_A_ (W)w);
2878 2906
2879 EV_FREQUENT_CHECK; 2907 EV_FREQUENT_CHECK;
2880} 2908}
2881#endif 2909#endif
2882 2910
2979once_cb (EV_P_ struct ev_once *once, int revents) 3007once_cb (EV_P_ struct ev_once *once, int revents)
2980{ 3008{
2981 void (*cb)(int revents, void *arg) = once->cb; 3009 void (*cb)(int revents, void *arg) = once->cb;
2982 void *arg = once->arg; 3010 void *arg = once->arg;
2983 3011
2984 ev_io_stop (EV_A_ &once->io); 3012 ev_io_stop (EV_A_ &once->io);
2985 ev_timer_stop (EV_A_ &once->to); 3013 ev_timer_stop (EV_A_ &once->to);
2986 ev_free (once); 3014 ev_free (once);
2987 3015
2988 cb (revents, arg); 3016 cb (revents, arg);
2989} 3017}
2990 3018
2991static void 3019static void
2992once_cb_io (EV_P_ ev_io *w, int revents) 3020once_cb_io (EV_P_ ev_io *w, int revents)
2993{ 3021{
2994 once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents); 3022 struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io));
3023
3024 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to));
2995} 3025}
2996 3026
2997static void 3027static void
2998once_cb_to (EV_P_ ev_timer *w, int revents) 3028once_cb_to (EV_P_ ev_timer *w, int revents)
2999{ 3029{
3000 once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents); 3030 struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to));
3031
3032 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io));
3001} 3033}
3002 3034
3003void 3035void
3004ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) 3036ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
3005{ 3037{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines